first
This commit is contained in:
39
node_modules/log-update/node_modules/onetime/index.js
generated
vendored
Normal file
39
node_modules/log-update/node_modules/onetime/index.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
const mimicFn = require('mimic-fn');
|
||||
|
||||
module.exports = (fn, opts) => {
|
||||
// TODO: Remove this in v3
|
||||
if (opts === true) {
|
||||
throw new TypeError('The second argument is now an options object');
|
||||
}
|
||||
|
||||
if (typeof fn !== 'function') {
|
||||
throw new TypeError('Expected a function');
|
||||
}
|
||||
|
||||
opts = opts || {};
|
||||
|
||||
let ret;
|
||||
let called = false;
|
||||
const fnName = fn.displayName || fn.name || '<anonymous>';
|
||||
|
||||
const onetime = function () {
|
||||
if (called) {
|
||||
if (opts.throw === true) {
|
||||
throw new Error(`Function \`${fnName}\` can only be called once`);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
called = true;
|
||||
ret = fn.apply(this, arguments);
|
||||
fn = null;
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
mimicFn(onetime, fn);
|
||||
|
||||
return onetime;
|
||||
};
|
21
node_modules/log-update/node_modules/onetime/license
generated
vendored
Normal file
21
node_modules/log-update/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.
|
72
node_modules/log-update/node_modules/onetime/package.json
generated
vendored
Normal file
72
node_modules/log-update/node_modules/onetime/package.json
generated
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
{
|
||||
"_from": "onetime@^2.0.0",
|
||||
"_id": "onetime@2.0.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-oyyPpiMaKARvvcgip+JV+7zci5L8D1W9RZIz2l1o08AM3pfspitVWnPt3mzHcBPp12oYMTy0pqrFs/C+m3EwsQ==",
|
||||
"_location": "/log-update/onetime",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "onetime@^2.0.0",
|
||||
"name": "onetime",
|
||||
"escapedName": "onetime",
|
||||
"rawSpec": "^2.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/log-update/restore-cursor"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz",
|
||||
"_shasum": "067428230fd67443b2794b22bba528b6867962d4",
|
||||
"_spec": "onetime@^2.0.0",
|
||||
"_where": "C:\\Users\\zhouxueli\\Desktop\\scheduling-app\\node_modules\\log-update\\node_modules\\restore-cursor",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/onetime/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"mimic-fn": "^1.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Ensure a function is only called once",
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/sindresorhus/onetime#readme",
|
||||
"keywords": [
|
||||
"once",
|
||||
"function",
|
||||
"one",
|
||||
"onetime",
|
||||
"func",
|
||||
"fn",
|
||||
"single",
|
||||
"call",
|
||||
"called",
|
||||
"prevent"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "onetime",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sindresorhus/onetime.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "2.0.1"
|
||||
}
|
65
node_modules/log-update/node_modules/onetime/readme.md
generated
vendored
Normal file
65
node_modules/log-update/node_modules/onetime/readme.md
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
# onetime [](https://travis-ci.org/sindresorhus/onetime)
|
||||
|
||||
> Ensure a function is only called 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
|
||||
```
|
||||
|
||||
```js
|
||||
const foo = onetime(() => {}, {throw: true});
|
||||
|
||||
foo();
|
||||
|
||||
foo();
|
||||
//=> Error: Function `foo` can only be called once
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### onetime(fn, [options])
|
||||
|
||||
Returns a function that only calls `fn` once.
|
||||
|
||||
#### fn
|
||||
|
||||
Type: `Function`
|
||||
|
||||
Function that should only be called once.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`
|
||||
|
||||
##### throw
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Throw an error when called more than once.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
Reference in New Issue
Block a user