Deployed the page to Github Pages.
This commit is contained in:
parent
1d79754e93
commit
2c89899458
62797 changed files with 6551425 additions and 15279 deletions
21
node_modules/copy-anything/LICENSE
generated
vendored
Normal file
21
node_modules/copy-anything/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2018 Luca Ban - Mesqueeb
|
||||
|
||||
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.
|
130
node_modules/copy-anything/README.md
generated
vendored
Normal file
130
node_modules/copy-anything/README.md
generated
vendored
Normal file
|
@ -0,0 +1,130 @@
|
|||
# Copy anything 🎭
|
||||
|
||||
<a href="https://www.npmjs.com/package/copy-anything"><img src="https://img.shields.io/npm/v/copy-anything.svg" alt="Total Downloads"></a>
|
||||
<a href="https://www.npmjs.com/package/copy-anything"><img src="https://img.shields.io/npm/dw/copy-anything.svg" alt="Latest Stable Version"></a>
|
||||
|
||||
```
|
||||
npm i copy-anything
|
||||
```
|
||||
|
||||
An optimised way to copy'ing (cloning) an object or array. A small and simple integration.
|
||||
|
||||
## Motivation
|
||||
|
||||
I created this package because I tried a lot of similar packages that do copy'ing/cloning. But all had its quirks, and _all of them break things they are not supposed to break_... 😞
|
||||
|
||||
I was looking for:
|
||||
|
||||
- a simple copy/clone function
|
||||
- has to be fast!
|
||||
- props must lose any reference to original object
|
||||
- works with arrays and objects in arrays!
|
||||
- supports symbols
|
||||
- can copy non-enumerable props as well
|
||||
- **does not break special class instances** ‼️
|
||||
|
||||
This last one is crucial! So many libraries use custom classes that create objects with special prototypes, and such objects all break when trying to copy them inproperly. So we gotta be careful!
|
||||
|
||||
copy-anything will copy objects and nested properties, but only as long as they're "plain objects". As soon as a sub-prop is not a "plain object" and has a special prototype, it will copy that instance over "as is". ♻️
|
||||
|
||||
## Meet the family
|
||||
|
||||
- [copy-anything 🎭](https://github.com/mesqueeb/copy-anything)
|
||||
- [merge-anything 🥡](https://github.com/mesqueeb/merge-anything)
|
||||
- [filter-anything ⚔️](https://github.com/mesqueeb/filter-anything)
|
||||
- [find-and-replace-anything 🎣](https://github.com/mesqueeb/find-and-replace-anything)
|
||||
- [compare-anything 🛰](https://github.com/mesqueeb/compare-anything)
|
||||
- [flatten-anything 🏏](https://github.com/mesqueeb/flatten-anything)
|
||||
- [is-what 🙉](https://github.com/mesqueeb/is-what)
|
||||
|
||||
## Usage
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
```js
|
||||
import { copy } from 'copy-anything'
|
||||
|
||||
const original = { name: 'Ditto', type: { water: true } }
|
||||
const copy = copy(original)
|
||||
|
||||
// now if we change a nested prop like the type
|
||||
copy.type.water = false
|
||||
// or add a new nested prop
|
||||
copy.type.fire = true
|
||||
|
||||
// then the original object will still be the same:
|
||||
(original.type.water === true) // true
|
||||
(original.type.fire === undefined) // true
|
||||
```
|
||||
|
||||
> Please note, by default copy-anything does not copy non-enumerable props. If you need to copy those, see the instructions further down below.
|
||||
|
||||
## Works with arrays
|
||||
|
||||
It will also clone arrays, **as well as objects inside arrays!** 😉
|
||||
|
||||
```js
|
||||
const original = [{ name: 'Squirtle' }]
|
||||
const copy = copy(original)
|
||||
|
||||
// now if we change a prop in the array
|
||||
copy[0].name = 'Wartortle'
|
||||
// or add a new item to the array
|
||||
copy.push({ name: 'Charmander' })
|
||||
|
||||
// then the original array will still be the same:
|
||||
(original[0].name === 'Squirtle') // true
|
||||
(original[1] === undefined) // true
|
||||
```
|
||||
|
||||
## Non-enumerable
|
||||
|
||||
By default, copy-anything only copies enumerable properties. If you also want to copy non-enumerable properties you can do so by passing that as an option.
|
||||
|
||||
```js
|
||||
const original = { name: 'Bulbasaur' }
|
||||
// bulbasaur's ID is non-enumerable
|
||||
Object.defineProperty(original, 'id', {
|
||||
value: '001',
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
})
|
||||
const copy1 = copy(original)
|
||||
(copy1.id === undefined) // true
|
||||
|
||||
const copy2 = copy(original, { nonenumerable: true })
|
||||
(copy2.id === '001') // true
|
||||
```
|
||||
|
||||
## Limit to specific props
|
||||
|
||||
You can limit to specific props.
|
||||
|
||||
```js
|
||||
const original = { name: 'Flareon', type: ['fire'], id: '136' }
|
||||
const copy = copy(original, { props: ['name'] })
|
||||
|
||||
(copy) // will look like: `{ name: 'Flareon' }`
|
||||
```
|
||||
|
||||
> Please note, if the props you have specified are non-enumerable, you will also need to pass `{nonenumerable: true}`.
|
||||
|
||||
<!-- prettier-ignore-end -->
|
||||
## Source code
|
||||
|
||||
The source code is literally just these lines. Most of the magic comes from the isPlainObject function from the [is-what library](https://github.com/mesqueeb/is-what).
|
||||
|
||||
```JavaScript
|
||||
import { isPlainObject } from 'is-what'
|
||||
|
||||
export function copy (target) {
|
||||
if (isArray(target)) return target.map(i => copy(i))
|
||||
if (!isPlainObject(target)) return target
|
||||
return Object.keys(target)
|
||||
.reduce((carry, key) => {
|
||||
const val = target[key]
|
||||
carry[key] = copy(val)
|
||||
return carry
|
||||
}, {})
|
||||
}
|
||||
```
|
52
node_modules/copy-anything/dist/index.cjs
generated
vendored
Normal file
52
node_modules/copy-anything/dist/index.cjs
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var isWhat = require('is-what');
|
||||
|
||||
function assignProp(carry, key, newVal, originalObject, includeNonenumerable) {
|
||||
const propType = {}.propertyIsEnumerable.call(originalObject, key)
|
||||
? 'enumerable'
|
||||
: 'nonenumerable';
|
||||
if (propType === 'enumerable')
|
||||
carry[key] = newVal;
|
||||
if (includeNonenumerable && propType === 'nonenumerable') {
|
||||
Object.defineProperty(carry, key, {
|
||||
value: newVal,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copy (clone) an object and all its props recursively to get rid of any prop referenced of the original object. Arrays are also cloned, however objects inside arrays are still linked.
|
||||
*
|
||||
* @export
|
||||
* @template T
|
||||
* @param {T} target Target can be anything
|
||||
* @param {Options} [options = {}] Options can be `props` or `nonenumerable`
|
||||
* @returns {T} the target with replaced values
|
||||
* @export
|
||||
*/
|
||||
function copy(target, options = {}) {
|
||||
if (isWhat.isArray(target)) {
|
||||
return target.map((item) => copy(item, options));
|
||||
}
|
||||
if (!isWhat.isPlainObject(target)) {
|
||||
return target;
|
||||
}
|
||||
const props = Object.getOwnPropertyNames(target);
|
||||
const symbols = Object.getOwnPropertySymbols(target);
|
||||
return [...props, ...symbols].reduce((carry, key) => {
|
||||
if (isWhat.isArray(options.props) && !options.props.includes(key)) {
|
||||
return carry;
|
||||
}
|
||||
const val = target[key];
|
||||
const newVal = copy(val, options);
|
||||
assignProp(carry, key, newVal, target, options.nonenumerable);
|
||||
return carry;
|
||||
}, {});
|
||||
}
|
||||
|
||||
exports.copy = copy;
|
48
node_modules/copy-anything/dist/index.es.js
generated
vendored
Normal file
48
node_modules/copy-anything/dist/index.es.js
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
import { isArray, isPlainObject } from 'is-what';
|
||||
|
||||
function assignProp(carry, key, newVal, originalObject, includeNonenumerable) {
|
||||
const propType = {}.propertyIsEnumerable.call(originalObject, key)
|
||||
? 'enumerable'
|
||||
: 'nonenumerable';
|
||||
if (propType === 'enumerable')
|
||||
carry[key] = newVal;
|
||||
if (includeNonenumerable && propType === 'nonenumerable') {
|
||||
Object.defineProperty(carry, key, {
|
||||
value: newVal,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copy (clone) an object and all its props recursively to get rid of any prop referenced of the original object. Arrays are also cloned, however objects inside arrays are still linked.
|
||||
*
|
||||
* @export
|
||||
* @template T
|
||||
* @param {T} target Target can be anything
|
||||
* @param {Options} [options = {}] Options can be `props` or `nonenumerable`
|
||||
* @returns {T} the target with replaced values
|
||||
* @export
|
||||
*/
|
||||
function copy(target, options = {}) {
|
||||
if (isArray(target)) {
|
||||
return target.map((item) => copy(item, options));
|
||||
}
|
||||
if (!isPlainObject(target)) {
|
||||
return target;
|
||||
}
|
||||
const props = Object.getOwnPropertyNames(target);
|
||||
const symbols = Object.getOwnPropertySymbols(target);
|
||||
return [...props, ...symbols].reduce((carry, key) => {
|
||||
if (isArray(options.props) && !options.props.includes(key)) {
|
||||
return carry;
|
||||
}
|
||||
const val = target[key];
|
||||
const newVal = copy(val, options);
|
||||
assignProp(carry, key, newVal, target, options.nonenumerable);
|
||||
return carry;
|
||||
}, {});
|
||||
}
|
||||
|
||||
export { copy };
|
15
node_modules/copy-anything/dist/types/index.d.ts
generated
vendored
Normal file
15
node_modules/copy-anything/dist/types/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
export declare type Options = {
|
||||
props?: (string | symbol)[];
|
||||
nonenumerable?: boolean;
|
||||
};
|
||||
/**
|
||||
* Copy (clone) an object and all its props recursively to get rid of any prop referenced of the original object. Arrays are also cloned, however objects inside arrays are still linked.
|
||||
*
|
||||
* @export
|
||||
* @template T
|
||||
* @param {T} target Target can be anything
|
||||
* @param {Options} [options = {}] Options can be `props` or `nonenumerable`
|
||||
* @returns {T} the target with replaced values
|
||||
* @export
|
||||
*/
|
||||
export declare function copy<T>(target: T, options?: Options): T;
|
98
node_modules/copy-anything/package.json
generated
vendored
Normal file
98
node_modules/copy-anything/package.json
generated
vendored
Normal file
|
@ -0,0 +1,98 @@
|
|||
{
|
||||
"name": "copy-anything",
|
||||
"sideEffects": false,
|
||||
"version": "2.0.6",
|
||||
"description": "An optimised way to copy'ing an object. A small and simple integration",
|
||||
"module": "./dist/index.es.js",
|
||||
"main": "./dist/index.cjs",
|
||||
"types": "./dist/types/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.es.js",
|
||||
"require": "./dist/index.cjs",
|
||||
"types": "./dist/types/index.d.ts"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
"lint": "tsc --noEmit && eslint ./src --ext .ts",
|
||||
"build": "rollup -c ./scripts/build.js",
|
||||
"release": "npm run lint && del dist && npm run build && np"
|
||||
},
|
||||
"dependencies": {
|
||||
"is-what": "^3.14.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^5.10.1",
|
||||
"@typescript-eslint/parser": "^5.10.1",
|
||||
"del-cli": "^4.0.1",
|
||||
"eslint": "^8.7.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-tree-shaking": "^1.10.0",
|
||||
"np": "^7.6.0",
|
||||
"prettier": "^2.5.1",
|
||||
"rollup": "^2.66.0",
|
||||
"rollup-plugin-typescript2": "^0.31.1",
|
||||
"typescript": "^4.5.5",
|
||||
"vitest": "^0.2.1"
|
||||
},
|
||||
"keywords": [
|
||||
"copy",
|
||||
"clone",
|
||||
"json-stringify",
|
||||
"stringify-parse",
|
||||
"object",
|
||||
"copy-objects",
|
||||
"clone-objects",
|
||||
"json-stringify-json-parse",
|
||||
"deep-clone",
|
||||
"deep-copy",
|
||||
"typescript",
|
||||
"ts"
|
||||
],
|
||||
"author": "Luca Ban - Mesqueeb",
|
||||
"funding": "https://github.com/sponsors/mesqueeb",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/mesqueeb/copy-anything/issues"
|
||||
},
|
||||
"homepage": "https://github.com/mesqueeb/copy-anything#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/mesqueeb/copy-anything.git"
|
||||
},
|
||||
"np": {
|
||||
"yarn": false,
|
||||
"branch": "legacy"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"ignorePatterns": [
|
||||
"node_modules",
|
||||
"dist",
|
||||
"scripts",
|
||||
"test"
|
||||
],
|
||||
"root": true,
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": [
|
||||
"@typescript-eslint",
|
||||
"tree-shaking"
|
||||
],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"prettier"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/no-empty-function": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/ban-ts-ignore": "off",
|
||||
"tree-shaking/no-side-effects-in-initialization": "error",
|
||||
"@typescript-eslint/ban-ts-comment": "off"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue