拿掉 build files

This commit is contained in:
2022-07-18 16:33:23 +08:00
parent 41e2287bcb
commit 3707f158a3
31953 changed files with 0 additions and 4411796 deletions
-65
View File
@@ -1,65 +0,0 @@
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [2.0.4](https://github.com/nuxt-contrib/defu/compare/v2.0.3...v2.0.4) (2020-05-22)
### Bug Fixes
* correct path to types ([33d4bf0](https://github.com/nuxt-contrib/defu/commit/33d4bf0331e70b69a3a2a392f18a8f890d45d4f9))
### [2.0.3](https://github.com/nuxt-contrib/defu/compare/v2.0.2...v2.0.3) (2020-05-22)
### Bug Fixes
* specify type declaration file more precisely ([#15](https://github.com/nuxt-contrib/defu/issues/15)) ([6aa47d4](https://github.com/nuxt-contrib/defu/commit/6aa47d4a06a117b34b5e9231b04f8403056c2685))
### [2.0.2](https://github.com/nuxt-contrib/defu/compare/v2.0.1...v2.0.2) (2020-04-19)
### [2.0.1](https://github.com/nuxt-contrib/defu/compare/v2.0.0...v2.0.1) (2020-04-19)
### Docs
* Add note about `null`
## [2.0.0](https://github.com/nuxt-contrib/defu/compare/v1.0.0...v2.0.0) (2020-04-19)
### Features
* Support passing multiple defaults ([89ef702](https://github.com/nuxt-contrib/defu/commit/89ef702736b49cd48ca99a0dc64aa6ef3bd74e2d))
* Typescript rewrite ([9c906e6](https://github.com/nuxt-contrib/defu/commit/9c906e64459da64d77124224edb66034ce92f20c))
<a name="1.0.0"></a>
# [1.0.0](https://github.com/jsless/defu/compare/v0.0.4...v1.0.0) (2020-02-02)
<a name="0.0.4"></a>
## [0.0.4](https://github.com/jsless/defu/compare/v0.0.3...v0.0.4) (2020-01-01)
### Bug Fixes
* improve es5 compatibility ([#2](https://github.com/jsless/defu/issues/2), [#9](https://github.com/jsless/defu/issues/9)) ([5a6de7c](https://github.com/jsless/defu/commit/5a6de7c))
<a name="0.0.3"></a>
## [0.0.3](https://github.com/jsless/defu/compare/v0.0.1...v0.0.3) (2019-05-25)
<a name="0.0.2"></a>
## [0.0.2](https://github.com/jesless/defu/compare/v0.0.1...v0.0.2) (2019-05-25)
<a name="0.0.1"></a>
## 0.0.1 (2019-02-07)
### Bug Fixes
* imrpove non-object handlers ([f89fa28](https://github.com/jesless/defu/commit/f89fa28))
Generated Vendored
-21
View File
@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2019 - Pooya Parsa <pooya@pi0.ir>
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.
-155
View File
@@ -1,155 +0,0 @@
![defu](.github/banner.svg)
# 🌊 defu
> Assign default properties, recursively. Lightweight and Fast!
[![Standard JS][standard-src]][standard-href]
[![david dm][david-src]][david-href]
[![codecov][codecov-src]][codecov-href]
[![npm version][npm-v-src]][npm-v-href]
[![npm downloads][npm-dm-src]][npm-dm-href]
[![package phobia][packagephobia-src]][packagephobia-href]
[![bundle phobia][bundlephobia-src]][bundlephobia-href]
## Install
Install package:
```bash
yarn add defu
# or
npm install defu
```
## Usage
```js
const options = defu (object, ...defaults)
```
Leftmost arguments have more priority when assigning defaults.
### Arguments
- **object (Object):** The destination object.
- **source (Object):** The source object.
```js
const defu = require('defu')
console.log(defu({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }))
// => { a: { b: 2, c: 3 } }
```
## Custom Merger
Sometimes default merging strategy is not desirable. Using `defu.extend` we can create a custom instance with different merging strategy.
This function accepts `obj` (source object), `key` and `value` (current value) and should return `true` if applied custom merging.
**Example:** Sum numbers instead of overriding
```js
const ext = defu.extend((obj, key, value) => {
if (typeof obj[key] === 'number' && typeof value === 'number') {
obj[key] += val
return true
}
})
ext({ cost: 15 }, { cost: 10 }) // { cost: 25 }
```
## Function Merger
Using `defu.fn`, if user provided a function, it will be called with default value instead of merging.
I can be useful for default values manipulation.
**Example:** Filter some items from defaults (array) and add 20 to the count default value.
```js
defu.fn({
ignore: (val) => val.filter(item => item !== 'dist'),
count: (count) => count + 20
}, {
ignore: ['node_modules','dist'],
count: 10
})
/*
{
ignore: ['node_modules'],
count: 30
}
*/
```
**Note:** if the default value is not defined, the function defined won't be called and kept as value.
## Array Function Merger
`defu.arrayFn` is similar to `defu.fn` but **only applies to array values defined in defaults**.
**Example:** Filter some items from defaults (array) and add 20 to the count default value.
```js
defu.arrayFn({
ignore(val) => val.filter(i => i !== 'dist'),
count: () => 20
}, {
ignore: [
'node_modules',
'dist'
],
count: 10
})
/*
{
ignore: ['node_modules'],
count: () => 20
}
*/
```
**Note:** the function is called only if the value defined in defaults is an aray.
### Remarks
- `object` and `defaults` are not modified
- Nullish values ([`null`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null) and [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined)) are skipped. Please use [defaults-deep](https://www.npmjs.com/package/defaults-deep) or [omit-deep](http://npmjs.com/package/omit-deep) or [lodash.defaultsdeep](https://www.npmjs.com/package/lodash.defaultsdeep) if you need to preserve or different behavior.
- Assignment of `__proto__` and `constructor` keys will be skipped to prevent security issues with object pollution.
- Will concat `array` values (if default property is defined)
```js
console.log(defu({ array: ['b', 'c'] }, { array: ['a'] }))
// => { array: ['a', 'b', 'c']}
```
## License
MIT. Made with 💖
<!-- Refs -->
[standard-src]: https://flat.badgen.net/badge/code%20style/standard/green
[standard-href]: https://standardjs.com
[npm-v-src]: https://flat.badgen.net/npm/v/defu/latest
[npm-v-href]: https://npmjs.com/package/defu
[npm-dm-src]: https://flat.badgen.net/npm/dm/defu
[npm-dm-href]: https://npmjs.com/package/defu
[packagephobia-src]: https://flat.badgen.net/packagephobia/install/defu
[packagephobia-href]: https://packagephobia.now.sh/result?p=defu
[bundlephobia-src]: https://flat.badgen.net/bundlephobia/min/defu
[bundlephobia-href]: https://bundlephobia.com/result?p=defu
[david-src]: https://flat.badgen.net/david/dep/unjs/defu
[david-href]: https://david-dm.org/unjs/defu
[codecov-src]: https://flat.badgen.net/codecov/c/github/unjs/defu/master
[codecov-href]: https://codecov.io/gh/unjs/defu
-50
View File
@@ -1,50 +0,0 @@
'use strict';
function isObject(val) {
return val !== null && typeof val === "object";
}
function _defu(baseObj, defaults, namespace = ".", merger) {
if (!isObject(defaults)) {
return _defu(baseObj, {}, namespace, merger);
}
const obj = Object.assign({}, defaults);
for (const key in baseObj) {
if (key === "__proto__" || key === "constructor") {
continue;
}
const val = baseObj[key];
if (val === null || val === void 0) {
continue;
}
if (merger && merger(obj, key, val, namespace)) {
continue;
}
if (Array.isArray(val) && Array.isArray(obj[key])) {
obj[key] = obj[key].concat(val);
} else if (isObject(val) && isObject(obj[key])) {
obj[key] = _defu(val, obj[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
} else {
obj[key] = val;
}
}
return obj;
}
function extend(merger) {
return (...args) => args.reduce((p, c) => _defu(p, c, "", merger), {});
}
const defu = extend();
defu.fn = extend((obj, key, currentValue, _namespace) => {
if (typeof obj[key] !== "undefined" && typeof currentValue === "function") {
obj[key] = currentValue(obj[key]);
return true;
}
});
defu.arrayFn = extend((obj, key, currentValue, _namespace) => {
if (Array.isArray(obj[key]) && typeof currentValue === "function") {
obj[key] = currentValue(obj[key]);
return true;
}
});
defu.extend = extend;
module.exports = defu;
-19
View File
@@ -1,19 +0,0 @@
declare type Input = Record<string | number | symbol, any>;
declare type Merger = <T extends Input, K extends keyof T>(obj: T, key: keyof T, value: T[K], namespace: string) => any;
declare type nullish = null | undefined | void;
declare type MergeObjects<Destination extends Input, Defaults extends Input> = Destination extends Defaults ? Destination : Omit<Destination, keyof Destination & keyof Defaults> & Omit<Defaults, keyof Destination & keyof Defaults> & {
-readonly [Key in keyof Destination & keyof Defaults]: Destination[Key] extends nullish ? Defaults[Key] extends nullish ? nullish : Defaults[Key] : Defaults[Key] extends nullish ? Destination[Key] : Merge<Destination[Key], Defaults[Key]>;
};
declare type DefuFn = <Source extends Input, Defaults extends Input>(source: Source, ...defaults: Defaults[]) => MergeObjects<Source, Defaults>;
interface Defu {
<Source extends Input, Defaults extends Input>(source: Source, ...defaults: Defaults[]): MergeObjects<Source, Defaults>;
fn: DefuFn;
arrayFn: DefuFn;
extend(merger?: Merger): DefuFn;
}
declare type MergeArrays<Destination, Source> = Destination extends Array<infer DestinationType> ? Source extends Array<infer SourceType> ? Array<DestinationType | SourceType> : Source | Array<DestinationType> : Source | Destination;
declare type Merge<Destination extends Input, Defaults extends Input> = Destination extends nullish ? Defaults extends nullish ? nullish : Defaults : Defaults extends nullish ? Destination : Destination extends Array<any> ? Defaults extends Array<any> ? MergeArrays<Destination, Defaults> : Destination | Defaults : Destination extends Function ? Destination | Defaults : Destination extends RegExp ? Destination | Defaults : Destination extends Promise<any> ? Destination | Defaults : Defaults extends Function ? Destination | Defaults : Defaults extends RegExp ? Destination | Defaults : Defaults extends Promise<any> ? Destination | Defaults : Destination extends Input ? Defaults extends Input ? MergeObjects<Destination, Defaults> : Destination | Defaults : Destination | Defaults;
declare const defu: Defu;
export { defu as default };
-63
View File
@@ -1,63 +0,0 @@
'use strict';
function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function isObject(val) {
return val !== null && _typeof(val) === 'object' && !Array.isArray(val);
}
function _defu(baseObj, defaults) {
if (!isObject(baseObj)) {
return _defu({}, defaults);
}
if (!isObject(defaults)) {
return _defu(baseObj, {});
}
var obj = Object.assign({}, defaults);
for (var key in baseObj) {
if (key === '__proto__' || key === 'constructor') {
continue;
}
var val = baseObj[key];
if (val === null) {
continue;
}
if (isObject(val) && isObject(obj[key])) {
obj[key] = _defu(val, obj[key]);
} else {
obj[key] = val;
}
}
return obj;
}
function defu() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return args.reduce(_defu, {});
}
module.exports = defu;
-48
View File
@@ -1,48 +0,0 @@
function isObject(val) {
return val !== null && typeof val === "object";
}
function _defu(baseObj, defaults, namespace = ".", merger) {
if (!isObject(defaults)) {
return _defu(baseObj, {}, namespace, merger);
}
const obj = Object.assign({}, defaults);
for (const key in baseObj) {
if (key === "__proto__" || key === "constructor") {
continue;
}
const val = baseObj[key];
if (val === null || val === void 0) {
continue;
}
if (merger && merger(obj, key, val, namespace)) {
continue;
}
if (Array.isArray(val) && Array.isArray(obj[key])) {
obj[key] = obj[key].concat(val);
} else if (isObject(val) && isObject(obj[key])) {
obj[key] = _defu(val, obj[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
} else {
obj[key] = val;
}
}
return obj;
}
function extend(merger) {
return (...args) => args.reduce((p, c) => _defu(p, c, "", merger), {});
}
const defu = extend();
defu.fn = extend((obj, key, currentValue, _namespace) => {
if (typeof obj[key] !== "undefined" && typeof currentValue === "function") {
obj[key] = currentValue(obj[key]);
return true;
}
});
defu.arrayFn = extend((obj, key, currentValue, _namespace) => {
if (Array.isArray(obj[key]) && typeof currentValue === "function") {
obj[key] = currentValue(obj[key]);
return true;
}
});
defu.extend = extend;
export { defu as default };
-76
View File
@@ -1,76 +0,0 @@
{
"_args": [
[
"defu@5.0.1",
"/home/node/nuxt"
]
],
"_from": "defu@5.0.1",
"_id": "defu@5.0.1",
"_inBundle": false,
"_integrity": "sha512-EPS1carKg+dkEVy3qNTqIdp2qV7mUP08nIsupfwQpz++slCVRw7qbQyWvSTig+kFPwz2XXp5/kIIkH+CwrJKkQ==",
"_location": "/defu",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "defu@5.0.1",
"name": "defu",
"escapedName": "defu",
"rawSpec": "5.0.1",
"saveSpec": null,
"fetchSpec": "5.0.1"
},
"_requiredBy": [
"/@nuxt/loading-screen",
"/@nuxt/telemetry",
"/@nuxtjs/axios",
"/serve-placeholder"
],
"_resolved": "https://registry.npmjs.org/defu/-/defu-5.0.1.tgz",
"_spec": "5.0.1",
"_where": "/home/node/nuxt",
"bugs": {
"url": "https://github.com/unjs/defu/issues"
},
"description": "Recursively assign default properties. Lightweight and Fast!",
"devDependencies": {
"@nuxtjs/eslint-config-typescript": "latest",
"@types/jest": "latest",
"@types/node": "latest",
"eslint": "latest",
"expect-type": "latest",
"jest": "latest",
"standard-version": "latest",
"ts-jest": "latest",
"typescript": "latest",
"unbuild": "latest"
},
"exports": {
".": {
"require": "./dist/defu.cjs",
"import": "./dist/defu.mjs"
}
},
"files": [
"dist"
],
"homepage": "https://github.com/unjs/defu#readme",
"license": "MIT",
"main": "./dist/defu.cjs",
"module": "./dist/defu.mjs",
"name": "defu",
"repository": {
"type": "git",
"url": "git+https://github.com/unjs/defu.git"
},
"scripts": {
"build": "unbuild",
"lint": "eslint --ext .ts src",
"prepack": "yarn build",
"release": "yarn test && standard-version && git push --follow-tags && npm publish",
"test": "yarn lint && yarn jest"
},
"types": "./dist/defu.d.ts",
"version": "5.0.1"
}