motion
Version:
motion - moving development forward
84 lines (83 loc) • 6.7 kB
JSON
{
"_args": [
[
"normalize-range@https://registry.npmjs.org/normalize-range/-/normalize-range-0.1.2.tgz",
"/Users/nw/flint/packages/flint"
]
],
"_from": "normalize-range@>=0.1.2 <0.2.0",
"_id": "normalize-range@0.1.2",
"_inCache": true,
"_location": "/normalize-range",
"_phantomChildren": {},
"_requested": {
"name": "normalize-range",
"raw": "normalize-range@https://registry.npmjs.org/normalize-range/-/normalize-range-0.1.2.tgz",
"rawSpec": "https://registry.npmjs.org/normalize-range/-/normalize-range-0.1.2.tgz",
"scope": null,
"spec": "https://registry.npmjs.org/normalize-range/-/normalize-range-0.1.2.tgz",
"type": "remote"
},
"_requiredBy": [
"/autoprefixer"
],
"_resolved": "https://registry.npmjs.org/normalize-range/-/normalize-range-0.1.2.tgz",
"_shasum": "2d10c06bdfd312ea9777695a4d28439456b75942",
"_shrinkwrap": null,
"_spec": "normalize-range@https://registry.npmjs.org/normalize-range/-/normalize-range-0.1.2.tgz",
"_where": "/Users/nw/flint/packages/flint",
"author": {
"email": "james@talmage.io",
"name": "James Talmage",
"url": "github.com/jamestalmage"
},
"bugs": {
"url": "https://github.com/jamestalmage/normalize-range/issues"
},
"dependencies": {},
"description": "Utility for normalizing a numeric range, with a wrapping function useful for polar coordinates",
"devDependencies": {
"almost-equal": "^1.0.0",
"codeclimate-test-reporter": "^0.1.0",
"coveralls": "^2.11.2",
"istanbul": "^0.3.17",
"jscs": "^2.1.1",
"jshint": "^2.8.0",
"jshint-stylish": "^2.0.1",
"mocha": "^2.2.5",
"stringify-pi": "0.0.3"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/jamestalmage/normalize-range#readme",
"keywords": [
"angle",
"degrees",
"normalize",
"polar",
"range",
"utility"
],
"license": "MIT",
"name": "normalize-range",
"optionalDependencies": {},
"readme": "# normalize-range \n\nUtility for normalizing a numeric range, with a wrapping function useful for polar coordinates.\n\n[](https://travis-ci.org/jamestalmage/normalize-range)\n[](https://coveralls.io/github/jamestalmage/normalize-range?branch=master)\n[](https://codeclimate.com/github/jamestalmage/normalize-range)\n[](https://david-dm.org/jamestalmage/normalize-range)\n[](https://david-dm.org/jamestalmage/normalize-range#info=devDependencies)\n\n[](https://nodei.co/npm/normalize-range/)\n\n## Usage\n\n```js\nvar nr = require('normalize-range');\n\nnr.wrap(0, 360, 400);\n//=> 40\n\nnr.wrap(0, 360, -90);\n//=> 270\n\nnr.limit(0, 100, 500);\n//=> 100\n\nnr.limit(0, 100, -20);\n//=> 0\n\n// There is a convenient currying function\nvar wrapAngle = nr.curry(0, 360).wrap;\nvar limitTo10 = nr.curry(0, 10).limit;\n\nwrapAngle(-30);\n//=> 330\n```\n## API\n\n### wrap(min, max, value)\n\nNormalizes a values that \"wraps around\". For example, in a polar coordinate system, 270˚ can also be\nrepresented as -90˚. \nFor wrapping purposes we assume `max` is functionally equivalent to `min`, and that `wrap(max + 1) === wrap(min + 1)`.\nWrap always assumes that `min` is *inclusive*, and `max` is *exclusive*.\nIn other words, if `value === max` the function will wrap it, and return `min`, but `min` will not be wrapped.\n\n```js\nnr.wrap(0, 360, 0) === 0;\nnr.wrap(0, 360, 360) === 0;\nnr.wrap(0, 360, 361) === 1;\nnr.wrap(0, 360, -1) === 359;\n```\n\nYou are not restricted to whole numbers, and ranges can be negative.\n\n```js\nvar π = Math.PI;\nvar radianRange = nr.curry(-π, π);\n\nredianRange.wrap(0) === 0;\nnr.wrap(π) === -π;\nnr.wrap(4 * π / 3) === -2 * π / 3;\n```\n\n### limit(min, max, value)\n\nNormalize the value by bringing it within the range.\nIf `value` is greater than `max`, `max` will be returned.\nIf `value` is less than `min`, `min` will be returned.\nOtherwise, `value` is returned unaltered.\nBoth ends of this range are *inclusive*.\n\n### test(min, max, value, [minExclusive], [maxExclusive])\n\nReturns `true` if `value` is within the range, `false` otherwise.\nIt defaults to `inclusive` on both ends of the range, but that can be\nchanged by setting `minExclusive` and/or `maxExclusive` to a truthy value.\n\n### validate(min, max, value, [minExclusive], [maxExclusive])\n\nReturns `value` or throws an error if `value` is outside the specified range.\n\n### name(min, max, value, [minExclusive], [maxExclusive])\n\nReturns a string representing this range in \n[range notation](https://en.wikipedia.org/wiki/Interval_(mathematics)#Classification_of_intervals).\n\n### curry(min, max, [minExclusive], [maxExclusive])\n\nConvenience method for currying all method arguments except `value`.\n\n```js\nvar angle = require('normalize-range').curry(-180, 180, false, true);\n\nangle.wrap(270)\n//=> -90\n\nangle.limit(200)\n//=> 180\n\nangle.test(0)\n//=> true\n\nangle.validate(300)\n//=> throws an Error\n\nangle.toString() // or angle.name()\n//=> \"[-180,180)\"\n```\n\n#### min\n\n*Required* \nType: `number`\n\nThe minimum value (inclusive) of the range.\n\n#### max\n\n*Required* \nType: `number`\n\nThe maximum value (exclusive) of the range.\n\n#### value\n\n*Required* \nType: `number`\n\nThe value to be normalized.\n\n#### returns\n\nType: `number`\n\nThe normalized value.\n\n## Building and Releasing\n\n- `npm test`: tests, linting, coverage and style checks.\n- `npm run watch`: autotest mode for active development.\n- `npm run debug`: run tests without coverage (istanbul can obscure line #'s) \n\nRelease via `cut-release` tool.\n\n## License\n\nMIT © [James Talmage](http://github.com/jamestalmage)\n",
"readmeFilename": "readme.md",
"repository": {
"type": "git",
"url": "git+https://github.com/jamestalmage/normalize-range.git"
},
"scripts": {
"cover": "istanbul cover ./node_modules/.bin/_mocha",
"debug": "mocha",
"lint": "jshint --reporter=node_modules/jshint-stylish *.js test/*.js",
"style": "jscs *.js ./**/*.js && jscs ./test/** --config=./test/.jscsrc",
"test": "npm run cover && npm run lint && npm run style",
"watch": "mocha -w"
},
"version": "0.1.2"
}