Update checked-in dependencies
This commit is contained in:
parent
4fad06f438
commit
40a500c743
4168 changed files with 298222 additions and 374905 deletions
16
node_modules/define-lazy-prop/index.d.ts
generated
vendored
16
node_modules/define-lazy-prop/index.d.ts
generated
vendored
|
|
@ -1,33 +1,31 @@
|
|||
/**
|
||||
Define a [lazily evaluated](https://en.wikipedia.org/wiki/Lazy_evaluation) property on an object.
|
||||
|
||||
@param object - Object to add property to.
|
||||
@param object - Object to add the property to.
|
||||
@param propertyName - Name of the property to add.
|
||||
@param fn - Called the first time `propertyName` is accessed.
|
||||
@param valueGetter - Called the first time `propertyName` is accessed.
|
||||
|
||||
@example
|
||||
```
|
||||
import defineLazyProp = require('define-lazy-prop');
|
||||
import defineLazyProperty from 'define-lazy-prop';
|
||||
|
||||
const unicorn = {
|
||||
// …
|
||||
};
|
||||
|
||||
defineLazyProp(unicorn, 'rainbow', () => expensiveComputation());
|
||||
defineLazyProperty(unicorn, 'rainbow', () => expensiveComputation());
|
||||
|
||||
app.on('user-action', () => {
|
||||
doSomething(unicorn.rainbow);
|
||||
});
|
||||
```
|
||||
*/
|
||||
declare function defineLazyProp<
|
||||
ObjectType extends {[key: string]: unknown},
|
||||
export default function defineLazyProperty<
|
||||
ObjectType extends Record<string, any>,
|
||||
PropertyNameType extends string,
|
||||
PropertyValueType
|
||||
>(
|
||||
object: ObjectType,
|
||||
propertyName: PropertyNameType,
|
||||
fn: () => PropertyValueType
|
||||
valueGetter: () => PropertyValueType
|
||||
): ObjectType & {[K in PropertyNameType]: PropertyValueType};
|
||||
|
||||
export = defineLazyProp;
|
||||
|
|
|
|||
7
node_modules/define-lazy-prop/index.js
generated
vendored
7
node_modules/define-lazy-prop/index.js
generated
vendored
|
|
@ -1,12 +1,11 @@
|
|||
'use strict';
|
||||
module.exports = (object, propertyName, fn) => {
|
||||
export default function defineLazyProperty(object, propertyName, valueGetter) {
|
||||
const define = value => Object.defineProperty(object, propertyName, {value, enumerable: true, writable: true});
|
||||
|
||||
Object.defineProperty(object, propertyName, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get() {
|
||||
const result = fn();
|
||||
const result = valueGetter();
|
||||
define(result);
|
||||
return result;
|
||||
},
|
||||
|
|
@ -16,4 +15,4 @@ module.exports = (object, propertyName, fn) => {
|
|||
});
|
||||
|
||||
return object;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
2
node_modules/define-lazy-prop/license
generated
vendored
2
node_modules/define-lazy-prop/license
generated
vendored
|
|
@ -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:
|
||||
|
||||
|
|
|
|||
15
node_modules/define-lazy-prop/package.json
generated
vendored
15
node_modules/define-lazy-prop/package.json
generated
vendored
|
|
@ -1,16 +1,19 @@
|
|||
{
|
||||
"name": "define-lazy-prop",
|
||||
"version": "2.0.0",
|
||||
"version": "3.0.0",
|
||||
"description": "Define a lazily evaluated property on an object",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/define-lazy-prop",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": "./index.js",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
"node": ">=12"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
|
|
@ -41,8 +44,8 @@
|
|||
"deferred"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
"ava": "^3.15.0",
|
||||
"tsd": "^0.14.0",
|
||||
"xo": "^0.38.2"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
23
node_modules/define-lazy-prop/readme.md
generated
vendored
23
node_modules/define-lazy-prop/readme.md
generated
vendored
|
|
@ -1,43 +1,40 @@
|
|||
# define-lazy-prop [](https://travis-ci.org/sindresorhus/define-lazy-prop)
|
||||
# define-lazy-prop
|
||||
|
||||
> Define a [lazily evaluated](https://en.wikipedia.org/wiki/Lazy_evaluation) property on an object
|
||||
|
||||
Useful when the value of a property is expensive to generate, so you want to delay the computation until the property is needed. For example, improving startup performance by deferring nonessential operations.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install define-lazy-prop
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const defineLazyProp = require('define-lazy-prop');
|
||||
import defineLazyProperty from 'define-lazy-prop';
|
||||
|
||||
const unicorn = {
|
||||
// …
|
||||
};
|
||||
|
||||
defineLazyProp(unicorn, 'rainbow', () => expensiveComputation());
|
||||
defineLazyProperty(unicorn, 'rainbow', () => expensiveComputation());
|
||||
|
||||
app.on('user-action', () => {
|
||||
doSomething(unicorn.rainbow);
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### defineLazyProp(object, propertyName, fn)
|
||||
### defineLazyProperty(object, propertyName, valueGetter)
|
||||
|
||||
#### object
|
||||
|
||||
Type: `Object`
|
||||
Type: `object`
|
||||
|
||||
Object to add property to.
|
||||
Object to add the property to.
|
||||
|
||||
#### propertyName
|
||||
|
||||
|
|
@ -45,20 +42,14 @@ Type: `string`
|
|||
|
||||
Name of the property to add.
|
||||
|
||||
#### fn
|
||||
#### valueGetter
|
||||
|
||||
Type: `Function`
|
||||
|
||||
Called the first time `propertyName` is accessed. Expected to return a value.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [lazy-value](https://github.com/sindresorhus/lazy-value) - Create a lazily evaluated value
|
||||
- [import-lazy](https://github.com/sindresorhus/import-lazy) - Import a module lazily
|
||||
- [p-lazy](https://github.com/sindresorhus/p-lazy) - Create a lazy promise
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue