New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

utilsac

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

utilsac - npm Package Compare versions

Comparing version 11.0.0 to 12.0.0

6

blobs.js
export {
downloadBlob
downloadBlob,
};
const downloadBlob = function (blob, name = "new_file.txt") {
const downloadBlob = function (blob, name = `new_file.txt`) {
const url = URL.createObjectURL(blob);
const anchor = document.createElement("a");
const anchor = document.createElement(`a`);
anchor.href = url;

@@ -9,0 +9,0 @@ anchor.download = name;

# Changelog
## 12.0.0
add
* deepCopyAdded
* deepAssignAdded
* deepEqual
* (Not yet implemented deepEqualAdded)
move
* deepAssign
* deepCopy
to deep.js
## 11.0.0

@@ -11,4 +25,4 @@

browse this commit dd5fbb65b377fc4174d9444d663debfdb3f1b628
or use 10.5.6 to keep using
browse this commit #dd5fbb65b377fc4174d9444d663debfdb3f1b628
or use 10.5.5 to keep using

@@ -15,0 +29,0 @@ ## 10.5.0

@@ -34,6 +34,6 @@ export { evalGlobal };

}
}
};
}
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
evalGlobalResolves.set(thisId, resolve);

@@ -40,0 +40,0 @@ document.body.appendChild(script);

{
"name": "utilsac",
"version": "11.0.0",
"version": "12.0.0",
"description": "Utility functions",

@@ -9,3 +9,5 @@ "type": "module",

"test": "ava",
"perftest": "node --experimental-modules ./tests/performance/deepCopy.js"
"perftest": "node --experimental-modules ./tests/performance/deepCopy.js",
"lint-fix": "eslint --ignore-path .gitignore --fix .",
"lint": "eslint --ignore-path .gitignore ."
},

@@ -29,2 +31,18 @@ "files": [

"license": "CC0-1.0",
"eslintConfig": {
"extends": [
"red"
],
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {}
},
"env": {
"es6": true,
"browser": true
},
"rules": {
}
},
"repository": {

@@ -36,2 +54,4 @@ "type": "git",

"ava": "^2.2.0",
"eslint": "^6.5.1",
"eslint-config-red": "^1.4.1",
"leistung": "^2.0.0"

@@ -41,3 +61,3 @@ },

"files": [
"tests/specification/**"
"tests/specification/**"
],

@@ -44,0 +64,0 @@ "require": [

@@ -7,7 +7,7 @@ # Utility functions

## utilsac
## Usage
## utility.js
```
```js
import {

@@ -24,4 +24,2 @@ createDebounced,

memoizeAsStrings,
deepCopy,
deepAssign,
createTemplateTag,

@@ -32,5 +30,18 @@ bytesLengthFromString,

## deep.js
```js
import {
deepCopy,
deepCopyAdded,
deepAssign,
deepAssignAdded,
deepEqual,
} from "utilsac/deep.js";
```
## typeCast.js
```
```js
import {

@@ -46,7 +57,7 @@ stringFromArrayBuffer,

```
```js
import { evalGlobal } from "utilsac/evalGlobal.js";
```
```
```js
evalGlobal(`window.x = 2 ** 10`);

@@ -58,3 +69,3 @@ ```

```
```js
evalGlobal(`

@@ -70,6 +81,15 @@ import sin form "./x.js";

```
```js
import { downloadBlob } from "utilsac/blobs.js";
```
## deep.js
### deepEqual example
```js
const personA = { email: 'example@example@email.com', name: { firstname: 'James', lastname: 'William' }};
const personB = { email: 'example@example@email.com', name: { firstname: 'James', lastname: 'William' }};
deepEqual(personA, personB) // Equal to true
```
## About

@@ -76,0 +96,0 @@

@@ -8,3 +8,3 @@ export {

const stringFromArrayBuffer = function (arrayBuffer, encoding = "utf-8") {
const stringFromArrayBuffer = function (arrayBuffer, encoding = `utf-8`) {
return (new TextDecoder(encoding)).decode(new DataView(arrayBuffer));

@@ -21,3 +21,3 @@ };

const reader = new FileReader();
reader.onload = function (event) {
reader.onload = function () {
resolve(reader.result);

@@ -24,0 +24,0 @@ };

@@ -12,4 +12,2 @@ export {

memoizeAsStrings,
deepCopy,
deepAssign,
createTemplateTag,

@@ -19,3 +17,5 @@ bytesLengthFromString,

const createDebounced = function (functionToDebounce, waitTime = 150) {
const waitTimeDefault = 150;
const createDebounced = function (functionToDebounce, waitTime = waitTimeDefault) {
/* creates a function that is de-bounced,

@@ -39,3 +39,5 @@ calling it, will eventually execute it, when you stop calling it

const createThrottled = function (functionToThrottle, minimumTimeSpace = 150) {
const minimumTimeSpaceDefault = 150;
const createThrottled = function (functionToThrottle, minimumTimeSpace = minimumTimeSpaceDefault) {
/* creates a function that is throttled,

@@ -58,3 +60,3 @@ calling it once will execute it immediately

const throttledWithLast = function (functionToThrottle, minimumTimeSpace = 150) {
const throttledWithLast = function (functionToThrottle, minimumTimeSpace = minimumTimeSpaceDefault, waitTime = waitTimeDefault) {
/* creates a function that is throttled,

@@ -100,3 +102,3 @@ calling it once will execute it immediately

resolves with an array of values or reject with the first error*/
const length = promiseCreators.length;
const {length} = promiseCreators;
const values = [];

@@ -125,5 +127,5 @@ let i = -1;

const values = [];
const length = functions.length;
const {length} = functions;
let i = 0;
const next = function (timing) {
const next = function () {
if (i < length) {

@@ -158,3 +160,3 @@ try {

}
return new Promise(function (resolve, reject) {
return new Promise(function (resolve) {
let i = 0;

@@ -191,3 +193,3 @@ const chainer = function (value) {

timeElapsed: endTime - startTime,
value
value,
};

@@ -219,63 +221,3 @@ });

/**
only works with undefined, null, Numbers, Symbols, Strings, Big Ints, Objects, Arrays,
warning does not work with cyclic objects, Dates, regexs
does not work with anything created with new
*/
const deepCopy = x => {
if (typeof x !== `object` || x === null) {
return x;
}
if (Array.isArray(x)) {
return x.map(deepCopy);
}
const copy = {}
Object.entries(x).forEach(([key, value]) => {
copy[key] = deepCopy(value);
});
return copy;
};
/**
Like Object.assign but deep,
does not try to assign partial arrays inside, they are overwritten
only works with undefined, null, Numbers, Symbols, Strings, Big Ints, Objects, Arrays,
warning does not work with cyclic objects, Dates, regexs
does not work with anything created with new
@param {Object} target must be an object
@param {Object} source1 should be an object, silently discards if not (like Object.assign)
@return {Object} target
*/
const deepAssign = (target, ...sources) => {
sources.forEach(source => {
if (!source || typeof source !== `object`) {
return;
}
Object.entries(source).forEach(([key, value]) => {
if (key === `__proto__`) {
return;
}
if (typeof value !== `object` || value === null) {
target[key] = value;
return;
}
if (Array.isArray(value)) {
target[key] = [];
}
// value is an Object
if (typeof target[key] !== `object` || !target[key]) {
target[key] = {};
}
deepAssign(target[key], value);
});
});
return target;
};
const createTemplateTag = (mapper) => {

@@ -291,3 +233,3 @@ /* creates a template tag function

return Array.from(parts, (part, index) => {
return `${staticStrings[index]}${mapper(part)}`
return `${staticStrings[index]}${mapper(part)}`;
}).concat(staticStrings[staticStrings.length - 1]).join(``);

@@ -297,6 +239,5 @@ };

const bytesLengthFromString = string => {
const textEncoder = new TextEncoder();
return textEncoder.encode(string).length;
};
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc