Deployed the page to Github Pages.
This commit is contained in:
parent
1d79754e93
commit
2c89899458
62797 changed files with 6551425 additions and 15279 deletions
59
node_modules/onetime/index.d.ts
generated
vendored
Normal file
59
node_modules/onetime/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
export interface Options {
|
||||
/**
|
||||
Throw an error when called more than once.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly throw?: boolean;
|
||||
}
|
||||
|
||||
declare const onetime: {
|
||||
/**
|
||||
Ensure a function is only called once. When called multiple times it will return the return value from the first call.
|
||||
|
||||
@param fn - Function that should only be called once.
|
||||
@returns A function that only calls `fn` once.
|
||||
|
||||
@example
|
||||
```
|
||||
import onetime from 'onetime';
|
||||
|
||||
let index = 0;
|
||||
|
||||
const foo = onetime(() => ++index);
|
||||
|
||||
foo(); //=> 1
|
||||
foo(); //=> 1
|
||||
foo(); //=> 1
|
||||
|
||||
onetime.callCount(foo); //=> 3
|
||||
```
|
||||
*/
|
||||
<ArgumentsType extends unknown[], ReturnType>(
|
||||
fn: (...arguments: ArgumentsType) => ReturnType,
|
||||
options?: Options
|
||||
): (...arguments: ArgumentsType) => ReturnType;
|
||||
|
||||
/**
|
||||
Get the number of times `fn` has been called.
|
||||
|
||||
@param fn - Function to get call count from.
|
||||
@returns A number representing how many times `fn` has been called.
|
||||
|
||||
@example
|
||||
```
|
||||
import onetime from 'onetime';
|
||||
|
||||
const foo = onetime(() => {});
|
||||
foo();
|
||||
foo();
|
||||
foo();
|
||||
|
||||
console.log(onetime.callCount(foo));
|
||||
//=> 3
|
||||
```
|
||||
*/
|
||||
callCount(fn: (...arguments: any[]) => unknown): number;
|
||||
};
|
||||
|
||||
export default onetime;
|
41
node_modules/onetime/index.js
generated
vendored
Normal file
41
node_modules/onetime/index.js
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
import mimicFunction from 'mimic-fn';
|
||||
|
||||
const calledFunctions = new WeakMap();
|
||||
|
||||
const onetime = (function_, options = {}) => {
|
||||
if (typeof function_ !== 'function') {
|
||||
throw new TypeError('Expected a function');
|
||||
}
|
||||
|
||||
let returnValue;
|
||||
let callCount = 0;
|
||||
const functionName = function_.displayName || function_.name || '<anonymous>';
|
||||
|
||||
const onetime = function (...arguments_) {
|
||||
calledFunctions.set(onetime, ++callCount);
|
||||
|
||||
if (callCount === 1) {
|
||||
returnValue = function_.apply(this, arguments_);
|
||||
function_ = null;
|
||||
} else if (options.throw === true) {
|
||||
throw new Error(`Function \`${functionName}\` can only be called once`);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
};
|
||||
|
||||
mimicFunction(onetime, function_);
|
||||
calledFunctions.set(onetime, callCount);
|
||||
|
||||
return onetime;
|
||||
};
|
||||
|
||||
onetime.callCount = function_ => {
|
||||
if (!calledFunctions.has(function_)) {
|
||||
throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
|
||||
}
|
||||
|
||||
return calledFunctions.get(function_);
|
||||
};
|
||||
|
||||
export default onetime;
|
9
node_modules/onetime/license
generated
vendored
Normal file
9
node_modules/onetime/license
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://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.
|
45
node_modules/onetime/package.json
generated
vendored
Normal file
45
node_modules/onetime/package.json
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"name": "onetime",
|
||||
"version": "6.0.0",
|
||||
"description": "Ensure a function is only called once",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/onetime",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": "./index.js",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"once",
|
||||
"function",
|
||||
"one",
|
||||
"onetime",
|
||||
"func",
|
||||
"fn",
|
||||
"single",
|
||||
"call",
|
||||
"called",
|
||||
"prevent"
|
||||
],
|
||||
"dependencies": {
|
||||
"mimic-fn": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^3.15.0",
|
||||
"tsd": "^0.14.0",
|
||||
"xo": "^0.38.2"
|
||||
}
|
||||
}
|
94
node_modules/onetime/readme.md
generated
vendored
Normal file
94
node_modules/onetime/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
# 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 and extending `Function.prototype`.*
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install onetime
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import onetime from 'onetime';
|
||||
|
||||
let index = 0;
|
||||
|
||||
const foo = onetime(() => ++index);
|
||||
|
||||
foo(); //=> 1
|
||||
foo(); //=> 1
|
||||
foo(); //=> 1
|
||||
|
||||
onetime.callCount(foo); //=> 3
|
||||
```
|
||||
|
||||
```js
|
||||
import onetime from 'onetime';
|
||||
|
||||
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`\
|
||||
Default: `false`
|
||||
|
||||
Throw an error when called more than once.
|
||||
|
||||
### onetime.callCount(fn)
|
||||
|
||||
Returns a number representing how many times `fn` has been called.
|
||||
|
||||
Note: It throws an error if you pass in a function that is not wrapped by `onetime`.
|
||||
|
||||
```js
|
||||
import onetime from 'onetime';
|
||||
|
||||
const foo = onetime(() => {});
|
||||
|
||||
foo();
|
||||
foo();
|
||||
foo();
|
||||
|
||||
console.log(onetime.callCount(foo));
|
||||
//=> 3
|
||||
```
|
||||
|
||||
#### fn
|
||||
|
||||
Type: `Function`
|
||||
|
||||
Function to get call count from.
|
||||
|
||||
## onetime for enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription.
|
||||
|
||||
The maintainers of onetime and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-onetime?utm_source=npm-onetime&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
Loading…
Add table
Add a link
Reference in a new issue