Init
This commit is contained in:
commit
4e066bffc9
10017 changed files with 1322084 additions and 0 deletions
31
node_modules/onetime/index.js
generated
vendored
Normal file
31
node_modules/onetime/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
'use strict';
|
||||
module.exports = function (fn, errMsg) {
|
||||
if (typeof fn !== 'function') {
|
||||
throw new TypeError('Expected a function');
|
||||
}
|
||||
|
||||
var ret;
|
||||
var called = false;
|
||||
var fnName = fn.displayName || fn.name || (/function ([^\(]+)/.exec(fn.toString()) || [])[1];
|
||||
|
||||
var onetime = function () {
|
||||
if (called) {
|
||||
if (errMsg === true) {
|
||||
fnName = fnName ? fnName + '()' : 'Function';
|
||||
throw new Error(fnName + ' can only be called once.');
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
called = true;
|
||||
ret = fn.apply(this, arguments);
|
||||
fn = null;
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
onetime.displayName = fnName;
|
||||
|
||||
return onetime;
|
||||
};
|
||||
21
node_modules/onetime/license
generated
vendored
Normal file
21
node_modules/onetime/license
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
97
node_modules/onetime/package.json
generated
vendored
Normal file
97
node_modules/onetime/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "onetime@^1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "onetime",
|
||||
"name": "onetime",
|
||||
"rawSpec": "^1.0.0",
|
||||
"spec": ">=1.0.0 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"/Users/jose/Documents/GitHub/About/node_modules/restore-cursor"
|
||||
]
|
||||
],
|
||||
"_from": "onetime@>=1.0.0 <2.0.0",
|
||||
"_id": "onetime@1.1.0",
|
||||
"_inCache": true,
|
||||
"_location": "/onetime",
|
||||
"_nodeVersion": "4.2.1",
|
||||
"_npmUser": {
|
||||
"name": "sindresorhus",
|
||||
"email": "sindresorhus@gmail.com"
|
||||
},
|
||||
"_npmVersion": "2.14.7",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "onetime@^1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "onetime",
|
||||
"name": "onetime",
|
||||
"rawSpec": "^1.0.0",
|
||||
"spec": ">=1.0.0 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/restore-cursor"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz",
|
||||
"_shasum": "a1f7838f8314c516f05ecefcbc4ccfe04b4ed789",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "onetime@^1.0.0",
|
||||
"_where": "/Users/jose/Documents/GitHub/About/node_modules/restore-cursor",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/onetime/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Only call a function once",
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "a1f7838f8314c516f05ecefcbc4ccfe04b4ed789",
|
||||
"tarball": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"gitHead": "6fae2fb77b95b49719d1c270d8ba07d9515bdfe8",
|
||||
"homepage": "https://github.com/sindresorhus/onetime",
|
||||
"keywords": [
|
||||
"once",
|
||||
"one",
|
||||
"single",
|
||||
"call",
|
||||
"function",
|
||||
"prevent"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "sindresorhus",
|
||||
"email": "sindresorhus@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "onetime",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sindresorhus/onetime.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "1.1.0"
|
||||
}
|
||||
52
node_modules/onetime/readme.md
generated
vendored
Normal file
52
node_modules/onetime/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
# onetime [](https://travis-ci.org/sindresorhus/onetime)
|
||||
|
||||
> Only call a function once
|
||||
|
||||
When called multiple times it will return the return value from the first call.
|
||||
|
||||
*Unlike the module [once](https://github.com/isaacs/once), this one isn't naughty extending `Function.prototype`.*
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save onetime
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
let i = 0;
|
||||
|
||||
const foo = onetime(() => i++);
|
||||
|
||||
foo(); //=> 0
|
||||
foo(); //=> 0
|
||||
foo(); //=> 0
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### onetime(function, [shouldThrow])
|
||||
|
||||
#### function
|
||||
|
||||
Type: `function`
|
||||
|
||||
Function that should only be called once.
|
||||
|
||||
#### shouldThrow
|
||||
|
||||
Type: `boolean`
|
||||
Default: `false`
|
||||
|
||||

|
||||
|
||||
Set to `true` if you want it to fail with a nice and descriptive error when called more than once.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
||||
Loading…
Reference in a new issue