UNPKG

canonical

Version:

Canonical code style linter and formatter for JavaScript, SCSS and CSS.

72 lines (71 loc) 2.75 kB
{ "_args": [ [ "onetime@https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", "/Users/gajus/Documents/dev/canonical-code-style/canonical" ] ], "_from": "onetime@>=1.0.0 <2.0.0", "_id": "onetime@1.1.0", "_inCache": true, "_location": "/onetime", "_phantomChildren": {}, "_requested": { "name": "onetime", "raw": "onetime@https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", "rawSpec": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", "scope": null, "spec": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", "type": "remote" }, "_requiredBy": [ "/restore-cursor" ], "_resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", "_shasum": "a1f7838f8314c516f05ecefcbc4ccfe04b4ed789", "_shrinkwrap": null, "_spec": "onetime@https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", "_where": "/Users/gajus/Documents/dev/canonical-code-style/canonical", "author": { "email": "sindresorhus@gmail.com", "name": "Sindre Sorhus", "url": "sindresorhus.com" }, "bugs": { "url": "https://github.com/sindresorhus/onetime/issues" }, "dependencies": {}, "description": "Only call a function once", "devDependencies": { "ava": "*", "xo": "*" }, "engines": { "node": ">=0.10.0" }, "files": [ "index.js" ], "homepage": "https://github.com/sindresorhus/onetime#readme", "keywords": [ "call", "function", "once", "one", "prevent", "single" ], "license": "MIT", "name": "onetime", "optionalDependencies": {}, "readme": "# onetime [![Build Status](https://travis-ci.org/sindresorhus/onetime.svg?branch=master)](https://travis-ci.org/sindresorhus/onetime)\n\n> Only call a function once\n\nWhen called multiple times it will return the return value from the first call.\n\n*Unlike the module [once](https://github.com/isaacs/once), this one isn't naughty extending `Function.prototype`.*\n\n\n## Install\n\n```\n$ npm install --save onetime\n```\n\n\n## Usage\n\n```js\nlet i = 0;\n\nconst foo = onetime(() => i++);\n\nfoo(); //=> 0\nfoo(); //=> 0\nfoo(); //=> 0\n```\n\n\n## API\n\n### onetime(function, [shouldThrow])\n\n#### function\n\nType: `function`\n\nFunction that should only be called once.\n\n#### shouldThrow\n\nType: `boolean` \nDefault: `false`\n\n![](screenshot-shouldthrow.png)\n\nSet to `true` if you want it to fail with a nice and descriptive error when called more than once.\n\n\n## License\n\nMIT © [Sindre Sorhus](http://sindresorhus.com)\n", "readmeFilename": "readme.md", "repository": { "type": "git", "url": "git+https://github.com/sindresorhus/onetime.git" }, "scripts": { "test": "xo && ava" }, "version": "1.1.0" }