{"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":"contra","email":"contra@wearefractal.com"},{"name":"phated","email":"blaine.bublitz@gmail.com"}],"dist":{"shasum":"e0bd5500cbd7e6f3cc22e86690da8ee6fc2879c2","tarball":"http://registry-npm.ywwl.com/value-or-function/download/value-or-function-1.2.0.tgz","integrity":"sha512-6dddCHe9SwHHBA0Cf2JioAVfwmgqdje/ikY5RX9pHrhcYgS1tkrpYZpudgC7h2WfLprLuofv1xiTtpWIbM+VZQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD3MY2eevlH3lolnMsXZVry6/2tSVoY3vTJdJtS2UH7eQIhAOiSyXA31wutmPYhc6WAzyiFZaYLZP/AiHoq14QotQOI"}],"size":2953,"noattachment":false,"key":"/value-or-function/-/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":{},"readme":"<p align=\"center\">\n  <a href=\"https://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][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-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(\n  'number',\n  function (a, b) {\n    return a + b;\n  },\n  1,\n  2\n);\n// count === 3\n\n// Supply the function with context\nvar context = { c: 3 };\nvar count = normalize.call(\n  context,\n  'number',\n  function (a, b) {\n    return a + b + this.c;\n  },\n  1,\n  2\n);\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<!-- prettier-ignore-start -->\n[downloads-image]: https://img.shields.io/npm/dm/value-or-function.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/value-or-function\n[npm-image]: https://img.shields.io/npm/v/value-or-function.svg?style=flat-square\n\n[ci-url]: https://github.com/gulpjs/value-or-function/actions?query=workflow:dev\n[ci-image]: https://img.shields.io/github/workflow/status/gulpjs/value-or-function/dev?style=flat-square\n\n[coveralls-url]: https://coveralls.io/r/gulpjs/value-or-function\n[coveralls-image]: https://img.shields.io/coveralls/gulpjs/value-or-function/master.svg?style=flat-square\n<!-- prettier-ignore-end -->\n","publish_time":1466358693513,"_cnpm_publish_time":1466358693513,"dist-tags":{"latest":"4.0.0"}}