Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2021-08-09 19:49:49 +00:00
parent 38bb211981
commit d6a5bf5c1c
96 changed files with 4450 additions and 174 deletions

25
node_modules/onetime/index.d.ts generated vendored
View file

@ -1,4 +1,4 @@
declare namespace oneTime {
declare namespace onetime {
interface Options {
/**
Throw an error when called more than once.
@ -9,16 +9,31 @@ declare namespace oneTime {
}
}
declare const oneTime: {
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 = require('onetime');
let i = 0;
const foo = onetime(() => ++i);
foo(); //=> 1
foo(); //=> 1
foo(); //=> 1
onetime.callCount(foo); //=> 3
```
*/
<ArgumentsType extends unknown[], ReturnType>(
fn: (...arguments: ArgumentsType) => ReturnType,
options?: oneTime.Options
options?: onetime.Options
): (...arguments: ArgumentsType) => ReturnType;
/**
@ -43,7 +58,7 @@ declare const oneTime: {
callCount(fn: (...arguments: any[]) => unknown): number;
// TODO: Remove this for the next major release
default: typeof oneTime;
default: typeof onetime;
};
export = oneTime;
export = onetime;

42
node_modules/onetime/index.js generated vendored
View file

@ -3,48 +3,42 @@ const mimicFn = require('mimic-fn');
const calledFunctions = new WeakMap();
const oneTime = (fn, options = {}) => {
if (typeof fn !== 'function') {
const onetime = (function_, options = {}) => {
if (typeof function_ !== 'function') {
throw new TypeError('Expected a function');
}
let ret;
let isCalled = false;
let returnValue;
let callCount = 0;
const functionName = fn.displayName || fn.name || '<anonymous>';
const functionName = function_.displayName || function_.name || '<anonymous>';
const onetime = function (...args) {
const onetime = function (...arguments_) {
calledFunctions.set(onetime, ++callCount);
if (isCalled) {
if (options.throw === true) {
throw new Error(`Function \`${functionName}\` can only be called once`);
}
return ret;
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`);
}
isCalled = true;
ret = fn.apply(this, args);
fn = null;
return ret;
return returnValue;
};
mimicFn(onetime, fn);
mimicFn(onetime, function_);
calledFunctions.set(onetime, callCount);
return onetime;
};
module.exports = oneTime;
module.exports = onetime;
// TODO: Remove this for the next major release
module.exports.default = oneTime;
module.exports.default = onetime;
module.exports.callCount = fn => {
if (!calledFunctions.has(fn)) {
throw new Error(`The given function \`${fn.name}\` is not wrapped by the \`onetime\` package`);
module.exports.callCount = function_ => {
if (!calledFunctions.has(function_)) {
throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
}
return calledFunctions.get(fn);
return calledFunctions.get(function_);
};

2
node_modules/onetime/license generated vendored
View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
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:

5
node_modules/onetime/package.json generated vendored
View file

@ -1,13 +1,14 @@
{
"name": "onetime",
"version": "5.1.0",
"version": "5.1.2",
"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": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"engines": {
"node": ">=6"

24
node_modules/onetime/readme.md generated vendored
View file

@ -1,4 +1,4 @@
# onetime [![Build Status](https://travis-ci.org/sindresorhus/onetime.svg?branch=master)](https://travis-ci.org/sindresorhus/onetime)
# onetime [![Build Status](https://travis-ci.com/sindresorhus/onetime.svg?branch=master)](https://travis-ci.com/github/sindresorhus/onetime)
> Ensure a function is only called once
@ -6,14 +6,12 @@ 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
@ -23,9 +21,9 @@ let i = 0;
const foo = onetime(() => ++i);
foo(); //=> 0
foo(); //=> 0
foo(); //=> 0
foo(); //=> 1
foo(); //=> 1
foo(); //=> 1
onetime.callCount(foo); //=> 3
```
@ -41,10 +39,9 @@ foo();
//=> Error: Function `foo` can only be called once
```
## API
### onetime(fn, [options])
### onetime(fn, options?)
Returns a function that only calls `fn` once.
@ -56,11 +53,11 @@ Function that should only be called once.
#### options
Type: `Object`
Type: `object`
##### throw
Type: `boolean`<br>
Type: `boolean`\
Default: `false`
Throw an error when called more than once.
@ -72,6 +69,8 @@ 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
const onetime = require('onetime');
const foo = onetime(() => {});
foo();
@ -88,7 +87,8 @@ Type: `Function`
Function to get call count from.
## onetime for enterprise
## License
Available as part of the Tidelift Subscription.
MIT © [Sindre Sorhus](https://sindresorhus.com)
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)