forked from BrianVaughan/joey_mc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json
38 lines (38 loc) · 3.88 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
"name": "over",
"description": "JavaScript function overloading framework.",
"author": {
"name": "Joe Ferner",
"email": "joe@fernsroth.com"
},
"keywords": [
"function",
"overload"
],
"version": "0.0.5",
"bugs": {
"url": "https://github.com/nearinfinity/node-over/issues"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/nearinfinity/node-over.git"
},
"main": "overload.js",
"scripts": {
"test": "./node_modules/.bin/nodeunit test"
},
"dependencies": {},
"devDependencies": {
"nodeunit": "~0.7.4"
},
"optionalDependencies": {},
"engines": {
"node": "*"
},
"readme": "# over\n\nJavaScript function overloading framework.\n\n## Installation\n\n```bash\n$ npm install over\n```\n\n## Quick Examples\n\n```javascript\nvar over = require('over');\n\nvar myfn = over([\n [over.string, function (str) { console.log('got a string' + str); }],\n [over.string, over.numberOptionalWithDefault(5), over.callbackOptional, function (str, number, callback) {\n console.log('got a string and a number and a callback');\n callback(str, number);\n }],\n function() {\n // default function if nothing else matches\n }\n]);\n```\n\n## Builtin Test functions\n\n* func\n* funcOptional\n* funcOptionalWithDefault\n* callbackOptional // Will return an empty function of parameter is not given\n* string\n* stringOptional\n* stringOptionalWithDefault\n* number\n* numberOptional\n* numberOptionalWithDefault\n* array\n* arrayOptional\n* arrayOptionalWithDefault\n* object\n* objectOptional\n* objectOptionalWithDefault\n\nThe built in optional functions with a suffix of \"WithDefault\" take a default value as well which will be used if\nit is not passed in.\n\n```javascript\nvar myfn = over([\n [over.stringOptionalWithDefault('default value'), function (str) { console.log('got a string' + str); }],\n]);\n```\n\n## Write your own test functions\n\nSimple optional test\n\n```javascript\nfunction greaterThan5Optional(arg) {\n return arg > 5;\n}\ngreaterThan5Optional.optional = true; // mark it as an optional parameter\n\nvar myfn = over([\n [greaterThan5Optional, function (v) { console.log('got a value' + v); }]\n]);\n```\n\nOptional test with default\n\n```javascript\nfunction greaterThan5OptionalWithDefault(def) {\n return function greaterThan5OptionalWithDefault2(arg) {\n if (arg === undefined) {\n return { defaultValue: def };\n }\n return arg > 5;\n }\n}\ngreaterThan5OptionalWithDefault.optional = true; // mark it as an optional parameter\n\nvar myfn = over([\n [greaterThan5OptionalWithDefault, function (v) { console.log('got a value' + v); }]\n]);\n```\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2012 Near Infinity Corporation\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
"readmeFilename": "README.md",
"homepage": "https://github.com/nearinfinity/node-over",
"_id": "over@0.0.5",
"_from": "over@~0.0.5"
}