{"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":{"integrity":"sha512-aeVK81SIuT6aMJfNo9Vte8Dw0/FZINGBV8BfCraGtqVxIeLAEhJyoWs8SmvRVmXfGss2PmmOwZCuBPbZR+IYWg==","shasum":"70836b6a876a010dc3a2b884e7902e9db064378d","tarball":"http://registry-npm.ywwl.com/value-or-function/download/value-or-function-4.0.0.tgz","fileCount":4,"unpackedSize":8626,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh9x2dCRA9TVsSAnZWagAA43wQAJwo0WXGO023fYcQhoF4\nbAW25vDjfWcAuYkn2jI5BDBgXUrc8sx3wMMdVvJolPjd8McKQQQ7TkJuSUqs\nWO1Yu/3hQ5Iuirshi1HZSByX9qHU23hP5Gc9YMGhzf1mZqIajR3qxfRV+NnH\noLJlzkY3tpK8MxZE8h27BV2u65nDAGM01aj2UUQ+FFv1WKFk07kYGVuanIOp\n5n+sGHlf5R25kUoUrChwYHyMD3M0xcUmvv8VYG9JArdXD92EyqNepORKgtRA\nAI/dmVbGem9/O7E2wX9B55OBQHJpZkl95PslVHGlU+PE+ESrratb5sSpib8g\nnPiFleL5JlCMxoYRb0X7h4Yy/yhH+647TwLmFXO+hvWaSs6zL/c0+Nw/D6Q3\nJVMrkjixwriYZ2MpQScMnr7zV8UDbDV2TF8UQBtf0fYocAf0a1vuskoQkF3H\nFFzK1cLB8oi/4/nEQb/Vr3GuBkmWTWuRDEgvQ4QdT1suUGaKOreI8l8MmZlu\nDnuNs5c+yZTvJJVbXwiU/6RHcjPCxfxHSOXhDof5gvSgUrMvrZ8MMNEP7ycs\nfwrm9tAWen29p7ME7HiCFJemb8rARBwK4Xl94q1dOd7OTui/+yg/DP8AfMFK\nl52a9rPgbEKIOAhipf89OqS7LigEmaIMGkJlEPQWn38BNyS2+qGshQQsfn8S\nua/i\r\n=IA9/\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGFbJjCwbCb1+Ttp++4a+hbh2f+Fw+/BGYIft31aI3HwAiAl/UExLdMhycj0aA+TIE/y1ijeMEB1GWeVS2GR+MKa0A=="}],"size":3339,"noattachment":false,"key":"/value-or-function/-/value-or-function-4.0.0.tgz"},"_npmUser":{"name":"phated","email":"blaine.bublitz@gmail.com"},"directories":{},"maintainers":[{"name":"yocontra","email":"yo@contra.io"},{"name":"phated","email":"blaine.bublitz@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/value-or-function_4.0.0_1643584925663_0.7225618484152039"},"_hasShrinkwrap":false,"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":1643584925848,"_cnpm_publish_time":1643584925848,"dist-tags":{"latest":"4.0.0"}}