Compare commits

...

7 Commits

Author SHA1 Message Date
7b2d4ba119 updated xhr error handling
All checks were successful
Build / Build NPM Project (push) Successful in 42s
Build / Tag Version (push) Successful in 4s
2024-06-25 09:58:02 -04:00
1a4e732fd5 deepMerge fix
All checks were successful
Build / Build NPM Project (push) Successful in 22s
Build / Tag Version (push) Successful in 5s
2024-06-18 21:08:18 -04:00
3a039c935f export deepMerge
All checks were successful
Build / Build NPM Project (push) Successful in 22s
Build / Tag Version (push) Successful in 4s
2024-06-18 20:19:10 -04:00
ac5b0b8b41 Added merge object
All checks were successful
Build / Build NPM Project (push) Successful in 21s
Build / Tag Version (push) Successful in 5s
2024-06-18 19:31:08 -04:00
3f85c9cf7d Updated package.json to include types file
All checks were successful
Build / Build NPM Project (push) Successful in 41s
Build / Tag Version (push) Successful in 5s
2024-06-17 10:23:48 -04:00
1eff60e7dd Fixed build
All checks were successful
Build / Build NPM Project (push) Successful in 22s
Build / Tag Version (push) Successful in 5s
2024-06-16 08:36:45 -04:00
1d9ad2ef63 Fixed module exports?
All checks were successful
Build / Build NPM Project (push) Successful in 38s
Build / Tag Version (push) Successful in 5s
Build / Publish (push) Successful in 7s
2024-06-16 08:29:49 -04:00
4 changed files with 39 additions and 35 deletions

View File

@ -37,11 +37,15 @@ jobs:
key: node_modules key: node_modules
pattern: node_modules pattern: node_modules
- name: Cache Artifacts - name: Upload to Registry
uses: ztimson/actions/cache@develop uses: ztimson/actions/npm/publish@develop
- name: Upload to NPM
uses: ztimson/actions/npm/publish@develop
with: with:
key: dist owner: ztimson
pattern: dist registry: https://registry.npmjs.org/
token: ${{secrets.NPM_TOKEN}}
tag: tag:
name: Tag Version name: Tag Version
needs: build needs: build
@ -59,31 +63,3 @@ jobs:
uses: ztimson/actions/tag@develop uses: ztimson/actions/tag@develop
with: with:
tag: ${{env.VERSION}} tag: ${{env.VERSION}}
publish:
name: Publish
needs: build
if: ${{github.ref_name}} == 'release'
runs-on: ubuntu-latest
container:
image: node
volumes:
- '/mnt/swarm/gitea/runner/cache:/cache'
steps:
- name: Clone Repository
uses: ztimson/actions/clone@develop
- name: Restore Artifacts
uses: ztimson/actions/cache/restore@develop
with:
key: dist
- name: Upload to Registry
uses: ztimson/actions/npm/publish@develop
- name: Upload to NPM
uses: ztimson/actions/npm/publish@develop
with:
owner: ztimson
registry: https://registry.npmjs.org/
token: ${{secrets.NPM_TOKEN}}

View File

@ -1,6 +1,6 @@
{ {
"name": "@ztimson/utils", "name": "@ztimson/utils",
"version": "0.11.0", "version": "0.12.3",
"description": "Utility library", "description": "Utility library",
"author": "Zak Timson", "author": "Zak Timson",
"license": "MIT", "license": "MIT",
@ -12,6 +12,13 @@
"main": "./dist/utils.cjs", "main": "./dist/utils.cjs",
"module": "./dist/utils.mjs", "module": "./dist/utils.mjs",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/utils.mjs",
"require": "./dist/utils.cjs",
"types": "./dist/index.d.ts"
}
},
"scripts": { "scripts": {
"build": "npx tsc && npx vite build", "build": "npx tsc && npx vite build",
"test": "npx jest", "test": "npx jest",

View File

@ -35,6 +35,27 @@ export function deepCopy<T>(value: T): T {
return JSON.parse(JSON.stringify(value)); return JSON.parse(JSON.stringify(value));
} }
/**
* Merge any number of objects into the target
*
* @param target Destination of all properties
* @param sources Objects that will copied into target
* @return {any} The des
*/
export function deepMerge<T>(target: any, ...sources: any[]): T {
sources.forEach(s => {
for(const key in s) {
if(s[key] && typeof s[key] == 'object' && !Array.isArray(s[key])) {
if(!target[key]) target[key] = {};
deepMerge(target[key], s[key]);
} else {
target[key] = s[key];
}
}
});
return target;
}
/** /**
* Get/set a property of an object using dot notation * Get/set a property of an object using dot notation
* *

View File

@ -83,8 +83,8 @@ export class XHR {
const payload = await decode(); const payload = await decode();
if(resp.ok) return payload; if(resp.ok) return payload;
const text = resp.statusText || (typeof payload == 'string' ? payload : null); throw Object.assign(new Error(typeof payload == 'string' ? payload : resp.statusText),
throw (text ? new Error(text) : payload); typeof payload == 'object' ? payload : {});
}); });
} }
} }