{"_id":"value-or-function","_rev":"3943985","name":"value-or-function","description":"Normalize a value or function, applying extra args to the function","dist-tags":{"latest":"4.0.0"},"maintainers":[{"name":"phated","email":"blaine.bublitz@gmail.com"},{"name":"yocontra","email":""}],"time":{"modified":"2025-09-01T01:32:44.000Z","created":"2016-04-01T22:53:01.754Z","4.0.0":"2022-01-30T23:22:05.848Z","3.0.0":"2017-07-21T20:47:58.213Z","2.0.0":"2016-08-17T23:07:05.322Z","1.2.1":"2016-07-15T23:31:31.453Z","1.2.0":"2016-06-19T17:51:33.513Z","1.1.0":"2016-06-07T22:30:23.349Z","1.0.0":"2016-04-01T22:53:01.754Z"},"users":{},"author":{"name":"Gulp Team","email":"team@gulpjs.com","url":"http://gulpjs.com/"},"repository":{"type":"git","url":"git+https://github.com/gulpjs/value-or-function.git"},"versions":{"4.0.0":{"name":"value-or-function","version":"4.0.0","description":"Normalize a value or function, applying extra args to the function","author":{"name":"Gulp Team","email":"team@gulpjs.com","url":"http://gulpjs.com/"},"contributors":[{"name":"Blaine Bublitz","email":"blaine.bublitz@gmail.com"},{"name":"Hugo Wood","email":"hx4.5@free.fr"}],"repository":{"type":"git","url":"git+https://github.com/gulpjs/value-or-function.git"},"license":"MIT","engines":{"node":">= 10.13.0"},"main":"index.js","scripts":{"lint":"eslint .","pretest":"npm run lint","test":"nyc mocha --async-only"},"devDependencies":{"eslint":"^7.32.0","eslint-config-gulp":"^5.0.1","eslint-plugin-node":"^11.1.0","expect":"^27.4.2","mocha":"^8.4.0","nyc":"^15.1.0","sinon":"^12.0.1"},"nyc":{"reporter":["lcov","text-summary"]},"prettier":{"singleQuote":true},"keywords":["options","normalize","value","function"],"gitHead":"2ec5fdbae61826dd3423c435d24b1caf0f7905a2","bugs":{"url":"https://github.com/gulpjs/value-or-function/issues"},"homepage":"https://github.com/gulpjs/value-or-function#readme","_id":"value-or-function@4.0.0","_nodeVersion":"16.13.0","_npmVersion":"7.24.2","dist":{"shasum":"70836b6a876a010dc3a2b884e7902e9db064378d","size":3339,"noattachment":false,"key":"/value-or-function/-/value-or-function-4.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/value-or-function/download/value-or-function-4.0.0.tgz"},"_npmUser":{"name":"phated","email":"blaine.bublitz@gmail.com"},"directories":{},"maintainers":[{"name":"phated","email":"blaine.bublitz@gmail.com"},{"name":"yocontra","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/value-or-function_4.0.0_1643584925663_0.7225618484152039"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-01-30T23:22:12.473Z","publish_time":1643584925848,"_cnpm_publish_time":1643584925848},"3.0.0":{"name":"value-or-function","version":"3.0.0","description":"Normalize a value or function, applying extra args to the function","author":{"name":"Gulp Team","email":"team@gulpjs.com","url":"http://gulpjs.com/"},"contributors":[{"name":"Blaine Bublitz","email":"blaine.bublitz@gmail.com"},{"name":"Hugo Wood","email":"hx4.5@free.fr"}],"repository":{"type":"git","url":"git+https://github.com/gulpjs/value-or-function.git"},"license":"MIT","engines":{"node":">= 0.10"},"main":"index.js","files":["index.js"],"scripts":{"lint":"eslint . && jscs index.js test/","pretest":"npm run lint","test":"mocha --async-only","cover":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly","coveralls":"npm run cover && istanbul-coveralls"},"dependencies":{},"devDependencies":{"eslint":"^1.10.3","eslint-config-gulp":"^2.0.0","expect":"^1.16.0","istanbul":"^0.4.3","istanbul-coveralls":"^1.0.3","jscs":"^2.3.5","jscs-preset-gulp":"^1.0.0","mocha":"^2.4.5"},"keywords":["options","normalize","value","function"],"gitHead":"44e5b5808a46a6e22fee66ad2508d2d1a0e1477c","bugs":{"url":"https://github.com/gulpjs/value-or-function/issues"},"homepage":"https://github.com/gulpjs/value-or-function#readme","_id":"value-or-function@3.0.0","_shasum":"1c243a50b595c1be54a754bfece8563b9ff8d813","_from":".","_npmVersion":"2.15.1","_nodeVersion":"0.10.48","_npmUser":{"name":"phated","email":"blaine.bublitz@gmail.com"},"maintainers":[{"name":"phated","email":"blaine.bublitz@gmail.com"},{"name":"yocontra","email":""}],"dist":{"shasum":"1c243a50b595c1be54a754bfece8563b9ff8d813","size":3314,"noattachment":false,"key":"/value-or-function/-/value-or-function-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/value-or-function/download/value-or-function-3.0.0.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/value-or-function-3.0.0.tgz_1500670075697_0.5566161137539893"},"directories":{},"publish_time":1500670078213,"_hasShrinkwrap":false,"_cnpm_publish_time":1500670078213},"2.0.0":{"name":"value-or-function","version":"2.0.0","description":"Normalize a value or function, applying extra args to the function","author":{"name":"Gulp Team","email":"team@gulpjs.com","url":"http://gulpjs.com/"},"contributors":[{"name":"Blaine Bublitz","email":"blaine.bublitz@gmail.com"},{"name":"Hugo Wood","email":"hx4.5@free.fr"}],"repository":{"type":"git","url":"git+https://github.com/gulpjs/value-or-function.git"},"license":"MIT","engines":{"node":">= 0.10"},"main":"index.js","files":["index.js"],"scripts":{"lint":"eslint . && jscs index.js test/","pretest":"npm run lint","test":"mocha --async-only","cover":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly","coveralls":"npm run cover && istanbul-coveralls"},"dependencies":{},"devDependencies":{"eslint":"^1.10.3","eslint-config-gulp":"^2.0.0","expect":"^1.16.0","istanbul":"^0.4.3","istanbul-coveralls":"^1.0.3","jscs":"^2.3.5","jscs-preset-gulp":"^1.0.0","mocha":"^2.4.5"},"keywords":["options","normalize","value","function"],"gitHead":"8a25e8a8b2f0b7cb0cc3991e9c4d58823a7cd079","bugs":{"url":"https://github.com/gulpjs/value-or-function/issues"},"homepage":"https://github.com/gulpjs/value-or-function#readme","_id":"value-or-function@2.0.0","_shasum":"887003b4dffcf38913890cb6c971e54cfac97f93","_from":".","_npmVersion":"2.15.2","_nodeVersion":"0.10.41","_npmUser":{"name":"phated","email":"blaine.bublitz@gmail.com"},"maintainers":[{"name":"phated","email":"blaine.bublitz@gmail.com"},{"name":"yocontra","email":""}],"dist":{"shasum":"887003b4dffcf38913890cb6c971e54cfac97f93","size":3219,"noattachment":false,"key":"/value-or-function/-/value-or-function-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/value-or-function/download/value-or-function-2.0.0.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/value-or-function-2.0.0.tgz_1471475223395_0.3799146863166243"},"directories":{},"publish_time":1471475225322,"_cnpm_publish_time":1471475225322,"_hasShrinkwrap":false},"1.2.1":{"name":"value-or-function","version":"1.2.1","description":"Normalize a value or function, applying extra args to the function","author":{"name":"Gulp Team","email":"team@gulpjs.com","url":"http://gulpjs.com/"},"contributors":[{"name":"Blaine Bublitz","email":"blaine.bublitz@gmail.com"},{"name":"Hugo Wood","email":"hx4.5@free.fr"}],"repository":{"type":"git","url":"git+https://github.com/gulpjs/value-or-function.git"},"license":"MIT","engines":{"node":">= 0.10"},"main":"index.js","files":["index.js"],"scripts":{"lint":"eslint . && jscs index.js test/","pretest":"npm run lint","test":"mocha --async-only","cover":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly","coveralls":"npm run cover && istanbul-coveralls"},"dependencies":{},"devDependencies":{"eslint":"^1.10.3","eslint-config-gulp":"^2.0.0","expect":"^1.16.0","istanbul":"^0.4.3","istanbul-coveralls":"^1.0.3","jscs":"^2.3.5","jscs-preset-gulp":"^1.0.0","mocha":"^2.4.5"},"keywords":["options","normalize","value","function"],"gitHead":"4bf80f2da5dd1fc33f82e1f25c989799e91a77bd","bugs":{"url":"https://github.com/gulpjs/value-or-function/issues"},"homepage":"https://github.com/gulpjs/value-or-function#readme","_id":"value-or-function@1.2.1","_shasum":"89c4f74ef3cd1340145f8c487510e26cf8bd3c85","_from":".","_npmVersion":"2.15.2","_nodeVersion":"0.10.41","_npmUser":{"name":"phated","email":"blaine.bublitz@gmail.com"},"maintainers":[{"name":"phated","email":"blaine.bublitz@gmail.com"},{"name":"yocontra","email":""}],"dist":{"shasum":"89c4f74ef3cd1340145f8c487510e26cf8bd3c85","size":3016,"noattachment":false,"key":"/value-or-function/-/value-or-function-1.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/value-or-function/download/value-or-function-1.2.1.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/value-or-function-1.2.1.tgz_1468625489532_0.616494545713067"},"directories":{},"publish_time":1468625491453,"_cnpm_publish_time":1468625491453,"_hasShrinkwrap":false},"1.2.0":{"name":"value-or-function","version":"1.2.0","description":"Normalize a value or function, applying extra args to the function","author":{"name":"Gulp Team","email":"team@gulpjs.com","url":"http://gulpjs.com/"},"contributors":[],"repository":{"type":"git","url":"git+https://github.com/gulpjs/value-or-function.git"},"license":"MIT","engines":{"node":">= 0.10"},"main":"index.js","files":["index.js"],"scripts":{"lint":"eslint . && jscs index.js test/","pretest":"npm run lint","test":"mocha --async-only","cover":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly","coveralls":"npm run cover && istanbul-coveralls"},"dependencies":{},"devDependencies":{"coveralls":"^2.11.2","eslint":"^1.10.3","eslint-config-gulp":"^2.0.0","expect":"^1.16.0","istanbul":"^0.4.0","istanbul-coveralls":"^1.0.1","jscs":"^2.3.5","jscs-preset-gulp":"^1.0.0","mocha":"^2.0.0","mocha-lcov-reporter":"^1.2.0"},"keywords":["options","normalize","value","function"],"gitHead":"2a51ee6180dbc96dffa50b68e5b638c3f647e71b","bugs":{"url":"https://github.com/gulpjs/value-or-function/issues"},"homepage":"https://github.com/gulpjs/value-or-function#readme","_id":"value-or-function@1.2.0","_shasum":"e0bd5500cbd7e6f3cc22e86690da8ee6fc2879c2","_from":".","_npmVersion":"2.15.2","_nodeVersion":"0.10.41","_npmUser":{"name":"phated","email":"blaine.bublitz@gmail.com"},"maintainers":[{"name":"phated","email":"blaine.bublitz@gmail.com"},{"name":"yocontra","email":""}],"dist":{"shasum":"e0bd5500cbd7e6f3cc22e86690da8ee6fc2879c2","size":2953,"noattachment":false,"key":"/value-or-function/-/value-or-function-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/value-or-function/download/value-or-function-1.2.0.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/value-or-function-1.2.0.tgz_1466358690789_0.8268043410498649"},"directories":{},"publish_time":1466358693513,"_cnpm_publish_time":1466358693513,"_hasShrinkwrap":false},"1.1.0":{"name":"value-or-function","version":"1.1.0","description":"Normalize a value or function, applying extra args to the function","author":{"name":"Gulp Team","email":"team@gulpjs.com","url":"http://gulpjs.com/"},"contributors":[],"repository":{"type":"git","url":"git+https://github.com/gulpjs/value-or-function.git"},"license":"MIT","engines":{"node":">= 0.10"},"main":"index.js","files":["index.js"],"scripts":{"lint":"eslint . && jscs index.js test/","pretest":"npm run lint","test":"mocha --async-only","cover":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly","coveralls":"npm run cover && istanbul-coveralls"},"dependencies":{},"devDependencies":{"coveralls":"^2.11.2","eslint":"^1.10.3","eslint-config-gulp":"^2.0.0","expect":"^1.16.0","istanbul":"^0.4.0","istanbul-coveralls":"^1.0.1","jscs":"^2.3.5","jscs-preset-gulp":"^1.0.0","mocha":"^2.0.0","mocha-lcov-reporter":"^1.2.0"},"keywords":["options","normalize","value","function"],"gitHead":"444b78ee7b3d4dad46ce62fe85a756e9d006663a","bugs":{"url":"https://github.com/gulpjs/value-or-function/issues"},"homepage":"https://github.com/gulpjs/value-or-function#readme","_id":"value-or-function@1.1.0","_shasum":"f7d85422d82f1054440122cf8fabc8ffe5e66f8c","_from":".","_npmVersion":"2.15.2","_nodeVersion":"0.10.41","_npmUser":{"name":"phated","email":"blaine.bublitz@gmail.com"},"maintainers":[{"name":"phated","email":"blaine.bublitz@gmail.com"},{"name":"yocontra","email":""}],"dist":{"shasum":"f7d85422d82f1054440122cf8fabc8ffe5e66f8c","size":2843,"noattachment":false,"key":"/value-or-function/-/value-or-function-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/value-or-function/download/value-or-function-1.1.0.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/value-or-function-1.1.0.tgz_1465338621421_0.35895483824424446"},"directories":{},"publish_time":1465338623349,"_cnpm_publish_time":1465338623349,"_hasShrinkwrap":false},"1.0.0":{"name":"value-or-function","version":"1.0.0","description":"Normalize a value or function, applying extra args to the function","author":{"name":"Gulp Team","email":"team@gulpjs.com","url":"http://gulpjs.com/"},"contributors":[],"repository":{"type":"git","url":"git+https://github.com/gulpjs/value-or-function.git"},"license":"MIT","engines":{"node":">= 0.10"},"main":"index.js","files":["index.js"],"scripts":{"lint":"eslint . && jscs index.js test/","pretest":"npm run lint","test":"mocha --async-only","cover":"istanbul cover _mocha --report lcovonly","coveralls":"npm run cover && istanbul-coveralls"},"dependencies":{},"devDependencies":{"coveralls":"^2.11.2","eslint":"^1.10.3","eslint-config-gulp":"^2.0.0","expect":"^1.16.0","istanbul":"^0.4.0","istanbul-coveralls":"^1.0.1","jscs":"^2.3.5","jscs-preset-gulp":"^1.0.0","mocha":"^2.0.0","mocha-lcov-reporter":"^1.2.0"},"keywords":["options","normalize","value","function"],"gitHead":"7e326ddb38a6280307d6f662b988fc531f2afba3","bugs":{"url":"https://github.com/gulpjs/value-or-function/issues"},"homepage":"https://github.com/gulpjs/value-or-function#readme","_id":"value-or-function@1.0.0","_shasum":"908b78429a55a31d946d0fe102129b80f8f5bde1","_from":".","_npmVersion":"2.15.2","_nodeVersion":"0.10.41","_npmUser":{"name":"phated","email":"blaine.bublitz@gmail.com"},"maintainers":[{"name":"phated","email":"blaine.bublitz@gmail.com"},{"name":"yocontra","email":""}],"dist":{"shasum":"908b78429a55a31d946d0fe102129b80f8f5bde1","size":2619,"noattachment":false,"key":"/value-or-function/-/value-or-function-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/value-or-function/download/value-or-function-1.0.0.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/value-or-function-1.0.0.tgz_1459551181209_0.5020108122844249"},"directories":{},"publish_time":1459551181754,"_cnpm_publish_time":1459551181754,"_hasShrinkwrap":false}},"readme":"<p align=\"center\">\n  <a href=\"http://gulpjs.com\">\n    <img height=\"257\" width=\"114\" src=\"https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png\">\n  </a>\n</p>\n\n# value-or-function\n\n[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]\n\nNormalize a value or function, applying extra args to the function\n\n## Example\n\n```js\nvar normalize = require('value-or-function');\n\n// Values matching type are returned\nvar isEnabled = normalize('boolean', true);\n// isEnabled === true\n\n// Values not matching type return undefined\nvar isEnabled = normalize('boolean', 1);\n// isEnabled === undefined\n\n// Functions are called\nvar isEnabled = normalize('boolean', function() {\n  return false;\n});\n// isEnabled === false\n\n// Extra arguments are applied to function\nvar count = normalize('number', function(a, b) {\n  return a + b;\n}, 1, 2);\n// count === 3\n\n// Supply the function with context\nvar context = { c: 3 };\nvar count = normalize.call(context, 'number', function(a, b) {\n  return a + b + this.c;\n}, 1, 2);\n// count === 6\n\n// Values one of multiple types are returned\nvar isEnabled = normalize(['string', 'boolean'], true);\n// isEnabled === true\n\n// Provide a function as first argument to do custom coercion\nvar now = new Date();\nvar enabledSince = normalize(function(value) {\n  if (value.constructor === Date) {\n    return value;\n  }\n}, now);\n// enabledSince === now\n\n// Convenience methods are available for the built-in types\nvar result = normalize.object({});\nvar result = normalize.number(1);\nvar result = normalize.string('');\nvar result = normalize.symbol(Symbol());\nvar result = normalize.boolean(true);\nvar result = normalize.function(function() {});\nvar result = normalize.date(new Date());\n```\n\n## API\n\n### `normalize(coercer, value[, ...appliedArguments])`\n\nTakes a coercer function `coercer` to transform `value` to the desired type.\nAlso optionally takes any extra arguments to apply to `value` if `value` is a function.\n\nIf the return value of `coercer(value)` is not `null` or `undefined`, that value is returned.\nOtherwise, if `value` is a function, that function is called with any extra arguments\nsupplied to `normalize`, and its return value is passed through the coercer.\n\nIf `coercer` is a string, it must be one of the built-in types (see below)\nand the appropriate default coercer is invoked, optionally first reducing `value`\nto a primitive type with `.valueOf()` if it is an Object.\n\nIf `coercer` is an array, each element is tried until one returns something other\nthan `null` or `undefined`, or it results in `undefined` if all of the elements yield `null` or `undefined`.\n\n#### `normalize.object(value[, ...appliedArguments])`\n\nConvenience method for `normalize('object', ...)`.\n\n#### `normalize.number(value[, ...appliedArguments])`\n\nConvenience method for `normalize('number', ...)`.\n\n#### `normalize.string(value[, ...appliedArguments])`\n\nConvenience method for `normalize('string', ...)`.\n\n#### `normalize.symbol(value[, ...appliedArguments])`\n\nConvenience method for `normalize('symbol', ...)`.\n\n#### `normalize.boolean(value[, ...appliedArguments])`\n\nConvenience method for `normalize('boolean', ...)`.\n\n#### `normalize.function(value[, ...appliedArguments])`\n\nConvenience method for `normalize('function', ...)`.\n\n#### `normalize.date(value[, ...appliedArguments])`\n\nConvenience method for `normalize('date', ...)`.\n\n## License\n\nMIT\n\n[downloads-image]: http://img.shields.io/npm/dm/value-or-function.svg\n[npm-url]: https://npmjs.org/package/value-or-function\n[npm-image]: http://img.shields.io/npm/v/value-or-function.svg\n\n[travis-url]: https://travis-ci.org/gulpjs/value-or-function\n[travis-image]: http://img.shields.io/travis/gulpjs/value-or-function.svg?label=travis-ci\n\n[appveyor-url]: https://ci.appveyor.com/project/gulpjs/value-or-function\n[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/value-or-function.svg?label=appveyor\n\n[coveralls-url]: https://coveralls.io/r/gulpjs/value-or-function\n[coveralls-image]: http://img.shields.io/coveralls/gulpjs/value-or-function/master.svg\n\n[gitter-url]: https://gitter.im/gulpjs/gulp\n[gitter-image]: https://badges.gitter.im/gulpjs/gulp.png\n","_attachments":{},"homepage":"https://github.com/gulpjs/value-or-function#readme","bugs":{"url":"https://github.com/gulpjs/value-or-function/issues"},"license":"MIT"}