https://github.com/grossacasac/utilsac
Utility functions
https://github.com/grossacasac/utilsac
deep-copy hacktoberfest javascript utility
Last synced: over 1 year ago
JSON representation
Utility functions
- Host: GitHub
- URL: https://github.com/grossacasac/utilsac
- Owner: GrosSacASac
- License: cc0-1.0
- Created: 2017-10-14T20:30:23.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2025-01-28T17:21:12.000Z (over 1 year ago)
- Last Synced: 2025-03-30T06:01:35.380Z (over 1 year ago)
- Topics: deep-copy, hacktoberfest, javascript, utility
- Language: JavaScript
- Homepage:
- Size: 942 KB
- Stars: 16
- Watchers: 2
- Forks: 7
- Open Issues: 7
-
Metadata Files:
- Readme: readme.md
- Changelog: changelog.md
- License: license.txt
Awesome Lists containing this project
README
# [utilsac](https://github.com/GrosSacASac/utilsac)
Utility functions
## Installation
[`npm i utilsac`](https://www.npmjs.com/package/utilsac)
## Usage
The source code is the documentation.
## utility.js
```js
import {
createDebounced,
createThrottled,
throttledWithLast,
chainPromiseNTimes,
chainPromises,
forceThrottlePromiseCreator,
throttlePromiseCreator,
throttlePromiseCreatorSelfClean,
somePromisesParallel,
chainRequestAnimationFrame,
decorateForceSequential,
doNTimes,
timeFunction,
timePromise,
memoizeAsStrings,
createTemplateTag,
bytesLengthFromString,
assignSelected,
} from "utilsac";
// deno
import {
createDebounced,
createThrottled,
throttledWithLast,
chainPromises,
somePromisesParallel,
chainRequestAnimationFrame,
doNTimes,
chainPromiseNTimes,
timeFunction,
timePromise,
memoizeAsStrings,
createTemplateTag,
bytesLengthFromString,
} from "https://unpkg.com/utilsac/utility.js";
```
## deep.js
Consider [structuredClone](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/structuredClone) if you need deepCopy
```js
import {
deepCopy,
deepCopyAdded,
deepAssign,
deepAssignAdded,
deepEqual,
deepEqualAdded,
deepDifference,
} from "utilsac/deep.js";
// deno
import {
deepCopy,
deepCopyAdded,
deepAssign,
deepAssignAdded,
deepEqual,
deepEqualAdded,
deepDifference,
} from "https://unpkg.com/utilsac/deep.js";
```
### deepEqual example
```js
const personA = { email: 'example@email.com', name: { firstname: 'James', lastname: 'William' }};
const personB = { email: 'example@email.com', name: { firstname: 'James', lastname: 'William' }};
deepEqual(personA, personB); // true
```
## typeCast.js
```js
import {
stringFromArrayBuffer,
arrayBufferFromBlob,
stringFromBlob,
stringFromArray,
setFromArray,
mapFromObject,
} from "utilsac/typeCast.js";
// deno
import {
deepCopy,
deepCopyAdded,
deepAssign,
deepAssignAdded,
deepEqual,
deepEqualAdded,
deepDifference,
} from "https://unpkg.com/utilsac/typeCast.js";
```
## typeCastNode.js
```js
import {
blobPromiseFromStream,
} from "utilsac/typeCastNode.js";
```
## browserUtility.js
```js
import {
evalGlobal,
downloadBlob,
} from "utilsac/browserUtility.js";
```
```js
evalGlobal(`window.x = 2 ** 10`);
```
After the Promise is resolved the code has executed in global scope.
```js
evalGlobal(`
import sin form "./x.js";
window.x = sin(Math.PI)
`, `module`);
```
Use optional second argument with `module` to be able to use static imports
## About
### Changelog
[Changelog](./changelog.md)
### License
[CC0](./license.txt)
### Related
* [JSON.prune to handle circular objects](https://github.com/Canop/JSON.prune)
* [stackoverflow answer to clone prototypes](https://stackoverflow.com/questions/122102/what-is-the-most-efficient-way-to-deep-clone-an-object-in-javascript)
* [fnk utility functions](https://github.com/seanohue/fnk)
* [lodash utility functions](https://lodash.com/)