This commit is contained in:
darenhsu
2022-07-17 13:16:16 +08:00
parent 84759556ff
commit befd344ab0
28070 changed files with 4008428 additions and 1 deletions
+65
View File
@@ -0,0 +1,65 @@
# 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
@@ -0,0 +1,21 @@
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.
+82
View File
@@ -0,0 +1,82 @@
# 🇩 defu
> Recursively assign default properties. Lightweight and Fast!
[![Standard JS][standard-src]][standard-href]
[![david dm][david-src]][david-href]
[![codecov][codecov-src]][codecov-href]
[![circleci][circleci-src]][circleci-href]
[![npm version][npm-v-src]][npm-v-href]
[![npm downloads][npm-dt-src]][npm-dt-href]
[![package phobia][packagephobia-src]][packagephobia-href]
[![bundle phobia][bundlephobia-src]][bundlephobia-href]
## Install
Install package:
```bash
npm install defu
```
OR
```bash
yarn add defu
```
## Usage
```js
const options = defu (object, ...defaults)
```
Most left arguments have more perioriry 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 } }
```
### Remarks
- `object` and `defaults` are not modified
- `null` values are skipped same as [defaults-deep](https://www.npmjs.com/package/defaults-deep). Please use either [omit-deep](http://npmjs.com/package/omit-deep) or [lodash.defaultsdeep](https://www.npmjs.com/package/lodash.defaultsdeep) if you need to to preserve.
- Assignment of `__proto__` and `constructor` keys will be skipped to prevent security issues with object pollution.
## 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-dt-src]: https://flat.badgen.net/npm/dt/defu
[npm-dt-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/jsless/defu
[david-href]: https://david-dm.org/jsless/defu
[codecov-src]: https://flat.badgen.net/codecov/c/github/jsless/defu/master
[codecov-href]: https://codecov.io/gh/jsless/defu
[circleci-src]: https://flat.badgen.net/circleci/github/jsless/defu/master
[circleci-href]: https://circleci.com/gh/jsless/defu
+5
View File
@@ -0,0 +1,5 @@
declare type defuObj = {
[key: string]: defuObj | any;
};
declare function defu<T extends defuObj>(...args: T | any): T;
export default defu;
+63
View File
@@ -0,0 +1,63 @@
'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;
+70
View File
@@ -0,0 +1,70 @@
{
"_args": [
[
"defu@2.0.4",
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
]
],
"_from": "defu@2.0.4",
"_id": "defu@2.0.4",
"_inBundle": false,
"_integrity": "sha512-G9pEH1UUMxShy6syWk01VQSRVs3CDWtlxtZu7A+NyqjxaCA4gSlWAKDBx6QiUEKezqS8+DUlXLI14Fp05Hmpwg==",
"_location": "/defu",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "defu@2.0.4",
"name": "defu",
"escapedName": "defu",
"rawSpec": "2.0.4",
"saveSpec": null,
"fetchSpec": "2.0.4"
},
"_requiredBy": [
"/@nuxt/config",
"/@nuxt/loading-screen",
"/@nuxt/telemetry",
"/@nuxtjs/axios",
"/rc9"
],
"_resolved": "https://registry.npmjs.org/defu/-/defu-2.0.4.tgz",
"_spec": "2.0.4",
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
"bugs": {
"url": "https://github.com/nuxt-contrib/defu/issues"
},
"description": "Recursively assign default properties. Lightweight and Fast!",
"devDependencies": {
"@nuxtjs/eslint-config-typescript": "latest",
"@types/jest": "latest",
"@types/node": "latest",
"bili": "latest",
"eslint": "latest",
"jest": "latest",
"rollup-plugin-typescript2": "latest",
"standard-version": "latest",
"ts-jest": "latest",
"typescript": "latest"
},
"files": [
"dist"
],
"homepage": "https://github.com/nuxt-contrib/defu#readme",
"license": "MIT",
"main": "./dist/defu.js",
"name": "defu",
"repository": {
"type": "git",
"url": "git+https://github.com/nuxt-contrib/defu.git"
},
"scripts": {
"build": "bili src/defu.ts",
"lint": "eslint --ext .ts src",
"prepublish": "yarn build",
"release": "yarn test && yarn build && standard-version && git push --follow-tags && npm publish",
"test": "yarn lint && yarn jest"
},
"types": "./dist/defu.d.ts",
"version": "2.0.4"
}