initial commit of actions

This commit is contained in:
2026-01-31 18:56:04 +01:00
commit 949ece5785
44660 changed files with 12034344 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
# just-extend
## 6.2.0
### Minor Changes
- Rename node module .js -> .cjs
## 6.1.1
### Patch Changes
- fix: reorder exports to set default last #488
## 6.1.0
### Minor Changes
- package.json updates to fix #467 and #483

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 angus croll
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.

View File

@@ -0,0 +1,48 @@
<!-- DO NOT EDIT THIS FILE! THIS FILE WAS AUTOGENERATED BY TEMPLATE-MATE -->
<!-- SEE https://github.com/angus-c/just/blob/master/CONTRIBUTING.md#readme-template -->
## just-extend
Part of a [library](https://anguscroll.com/just) of zero-dependency npm modules that do just do one thing.
Guilt-free utilities for every occasion.
[`🍦 Try it`](https://anguscroll.com/just/just-extend)
```shell
npm install just-extend
```
```shell
yarn add just-extend
```
Extend an object
```js
import extend from 'just-extend';
var obj = {a: 3, b: 5};
extend(obj, {a: 4, c: 8}); // {a: 4, b: 5, c: 8}
obj; // {a: 4, b: 5, c: 8}
var obj = {a: 3, b: 5};
extend({}, obj, {a: 4, c: 8}); // {a: 4, b: 5, c: 8}
obj; // {a: 3, b: 5}
var arr = [1, 2, 3];
var obj = {a: 3, b: 5};
extend(obj, {c: arr}); // {a: 3, b: 5, c: [1, 2, 3]}
arr.push(4);
obj; // {a: 3, b: 5, c: [1, 2, 3, 4]}
var arr = [1, 2, 3];
var obj = {a: 3, b: 5};
extend(true, obj, {c: arr}); // {a: 3, b: 5, c: [1, 2, 3]}
arr.push(4);
obj; // {a: 3, b: 5, c: [1, 2, 3]}
extend({a: 4, b: 5}); // {a: 4, b: 5}
extend({a: 4, b: 5}, 3); {a: 4, b: 5}
extend({a: 4, b: 5}, true); {a: 4, b: 5}
extend('hello', {a: 4, b: 5}); // throws
extend(3, {a: 4, b: 5}); // throws
```

View File

@@ -0,0 +1,72 @@
module.exports = extend;
/*
var obj = {a: 3, b: 5};
extend(obj, {a: 4, c: 8}); // {a: 4, b: 5, c: 8}
obj; // {a: 4, b: 5, c: 8}
var obj = {a: 3, b: 5};
extend({}, obj, {a: 4, c: 8}); // {a: 4, b: 5, c: 8}
obj; // {a: 3, b: 5}
var arr = [1, 2, 3];
var obj = {a: 3, b: 5};
extend(obj, {c: arr}); // {a: 3, b: 5, c: [1, 2, 3]}
arr.push(4);
obj; // {a: 3, b: 5, c: [1, 2, 3, 4]}
var arr = [1, 2, 3];
var obj = {a: 3, b: 5};
extend(true, obj, {c: arr}); // {a: 3, b: 5, c: [1, 2, 3]}
arr.push(4);
obj; // {a: 3, b: 5, c: [1, 2, 3]}
extend({a: 4, b: 5}); // {a: 4, b: 5}
extend({a: 4, b: 5}, 3); {a: 4, b: 5}
extend({a: 4, b: 5}, true); {a: 4, b: 5}
extend('hello', {a: 4, b: 5}); // throws
extend(3, {a: 4, b: 5}); // throws
*/
function extend(/* [deep], obj1, obj2, [objn] */) {
var args = [].slice.call(arguments);
var deep = false;
if (typeof args[0] == 'boolean') {
deep = args.shift();
}
var result = args[0];
if (isUnextendable(result)) {
throw new Error('extendee must be an object');
}
var extenders = args.slice(1);
var len = extenders.length;
for (var i = 0; i < len; i++) {
var extender = extenders[i];
for (var key in extender) {
if (Object.prototype.hasOwnProperty.call(extender, key)) {
var value = extender[key];
if (deep && isCloneable(value)) {
var base = Array.isArray(value) ? [] : {};
result[key] = extend(
true,
Object.prototype.hasOwnProperty.call(result, key) && !isUnextendable(result[key])
? result[key]
: base,
value
);
} else {
result[key] = value;
}
}
}
}
return result;
}
function isCloneable(obj) {
return Array.isArray(obj) || {}.toString.call(obj) == '[object Object]';
}
function isUnextendable(val) {
return !val || (typeof val != 'object' && typeof val != 'function');
}

View File

@@ -0,0 +1,4 @@
// Definitions by: Peter Safranek <https://github.com/pe8ter>
declare function extend(obj1: object, ...objn: any[]): object;
declare function extend(deep: boolean, obj1: object, ...objn: any[]): object;
export default extend;

View File

@@ -0,0 +1,74 @@
var objectExtend = extend;
/*
var obj = {a: 3, b: 5};
extend(obj, {a: 4, c: 8}); // {a: 4, b: 5, c: 8}
obj; // {a: 4, b: 5, c: 8}
var obj = {a: 3, b: 5};
extend({}, obj, {a: 4, c: 8}); // {a: 4, b: 5, c: 8}
obj; // {a: 3, b: 5}
var arr = [1, 2, 3];
var obj = {a: 3, b: 5};
extend(obj, {c: arr}); // {a: 3, b: 5, c: [1, 2, 3]}
arr.push(4);
obj; // {a: 3, b: 5, c: [1, 2, 3, 4]}
var arr = [1, 2, 3];
var obj = {a: 3, b: 5};
extend(true, obj, {c: arr}); // {a: 3, b: 5, c: [1, 2, 3]}
arr.push(4);
obj; // {a: 3, b: 5, c: [1, 2, 3]}
extend({a: 4, b: 5}); // {a: 4, b: 5}
extend({a: 4, b: 5}, 3); {a: 4, b: 5}
extend({a: 4, b: 5}, true); {a: 4, b: 5}
extend('hello', {a: 4, b: 5}); // throws
extend(3, {a: 4, b: 5}); // throws
*/
function extend(/* [deep], obj1, obj2, [objn] */) {
var args = [].slice.call(arguments);
var deep = false;
if (typeof args[0] == 'boolean') {
deep = args.shift();
}
var result = args[0];
if (isUnextendable(result)) {
throw new Error('extendee must be an object');
}
var extenders = args.slice(1);
var len = extenders.length;
for (var i = 0; i < len; i++) {
var extender = extenders[i];
for (var key in extender) {
if (Object.prototype.hasOwnProperty.call(extender, key)) {
var value = extender[key];
if (deep && isCloneable(value)) {
var base = Array.isArray(value) ? [] : {};
result[key] = extend(
true,
Object.prototype.hasOwnProperty.call(result, key) && !isUnextendable(result[key])
? result[key]
: base,
value
);
} else {
result[key] = value;
}
}
}
}
return result;
}
function isCloneable(obj) {
return Array.isArray(obj) || {}.toString.call(obj) == '[object Object]';
}
function isUnextendable(val) {
return !val || (typeof val != 'object' && typeof val != 'function');
}
export {objectExtend as default};

View File

@@ -0,0 +1,62 @@
import extend from './index'
// OK
// Pass single `object`.
extend({});
extend([]);
extend(() => {});
// Pass single `object`, then `any`.
extend({}, 0);
extend({}, "");
extend({}, false);
extend({}, null);
extend({}, undefined);
extend({}, {});
extend({}, []);
extend({}, () => {});
// Pass variadic args.
extend({}, 0, "", false, null, undefined, {}, [], () => {});
// Pass `boolean`, then single `object`.
extend(true, {});
extend(true, []);
extend(true, () => {});
// Pass `boolean`, single `object`, then `any`.
extend(true, {}, 0);
extend(true, {}, "");
extend(true, {}, false);
extend(true, {}, null);
extend(true, {}, undefined);
extend(true, {}, {});
extend(true, {}, []);
extend(true, {}, () => {});
// Pass `boolean`, then variadic args.
extend(true, {}, 0, "", false, null, undefined, {}, [], () => {});
// Not OK
// Incorrect extendee `object`.
// @ts-expect-error
extend();
// @ts-expect-error
extend(0);
// @ts-expect-error
extend("");
// @ts-expect-error
extend(false);
// @ts-expect-error
extend();
// @ts-expect-error
extend(true, 0);
// @ts-expect-error
extend(true, "");
// @ts-expect-error
extend(true, false);
// @ts-expect-error
extend(true);

View File

@@ -0,0 +1,37 @@
{
"name": "just-extend",
"version": "6.2.0",
"description": "extend an object",
"type": "module",
"exports": {
".": {
"types": "./index.d.ts",
"require": "./index.cjs",
"import": "./index.mjs"
},
"./package.json": "./package.json"
},
"main": "index.cjs",
"types": "index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rollup -c"
},
"repository": "https://github.com/angus-c/just",
"keywords": [
"object",
"assign",
"clone",
"copy",
"merge",
"deep-copy",
"extend",
"no-dependencies",
"just"
],
"author": "Angus Croll",
"license": "MIT",
"bugs": {
"url": "https://github.com/angus-c/just/issues"
}
}

View File

@@ -0,0 +1,3 @@
const createRollupConfig = require('../../config/createRollupConfig');
module.exports = createRollupConfig(__dirname);