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

@canvas-js/utils

Package Overview
Dependencies
Maintainers
0
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@canvas-js/utils - npm Package Compare versions

Comparing version 0.11.0 to 0.13.0-next.1

lib/filterMapEntries.d.ts

1

lib/index.d.ts

@@ -6,2 +6,3 @@ export * from "./assert.js";

export * from "./mapEntries.js";
export * from "./filterMapEntries.js";
export * from "./mapKeys.js";

@@ -8,0 +9,0 @@ export * from "./mapValues.js";

@@ -6,2 +6,3 @@ export * from "./assert.js";

export * from "./mapEntries.js";
export * from "./filterMapEntries.js";
export * from "./mapKeys.js";

@@ -8,0 +9,0 @@ export * from "./mapValues.js";

2

lib/mapValuesAsync.d.ts

@@ -1,1 +0,1 @@

export declare const mapValuesAsync: <K extends string, S, T>(object: Record<K, S>, map: (value: S) => Promise<T>) => Promise<any>;
export declare const mapValuesAsync: <K extends string, S, T>(object: Record<K, S>, map: (value: S) => Promise<T>) => Promise<Record<string, T>>;
import { zip } from "./zip.js";
export const mapValuesAsync = async (object, map) => {
const values = await Promise.all(Object.values(object).map((value) => map(value)));
return Object.fromEntries(zip(Object.keys(object), values));
const result = {};
for (const [k, v] of zip(Object.keys(object), values)) {
result[k] = v;
}
return result;
};

@@ -7,4 +7,12 @@ export type JSValue = null | boolean | number | string | Uint8Array | JSArray | JSObject;

}
export type FunctionalJSValue = null | boolean | number | string | Uint8Array | FunctionalJSArray | FunctionalJSObject | Function;
export interface FunctionalJSArray extends Array<FunctionalJSValue> {
}
export interface FunctionalJSObject {
[key: string]: FunctionalJSValue;
}
export type JSFunction = (...args: JSValue[]) => undefined | JSValue;
export type JSFunctionAsync = (...args: JSValue[]) => Promise<undefined | JSValue>;
export declare function typeOf(value: JSValue): "null" | "boolean" | "number" | "string" | "Uint8Array" | "Array" | "Object";
export declare function isObject(value: JSValue): value is JSObject;
export declare function merge(from: JSValue, into: JSValue): JSValue;

@@ -26,1 +26,45 @@ // Values

}
export function isObject(value) {
return typeOf(value) === "Object";
}
export function merge(from, into) {
if (from === null) {
return from;
}
else if (typeof from === "boolean") {
return from;
}
else if (typeof from === "number") {
return from;
}
else if (typeof from === "string") {
return from;
}
else if (from instanceof Uint8Array) {
return from;
}
else if (Array.isArray(from)) {
return from;
}
else {
// only merge objects
if (!isObject(from))
return from;
if (!isObject(into))
return from;
const mergedKeys = Array.from(new Set([...Object.keys(from), ...Object.keys(into)]));
const result = {};
for (const key of mergedKeys) {
if (from[key] === undefined) {
result[key] = into[key];
}
else if (into[key] === undefined) {
result[key] = from[key];
}
else {
result[key] = merge(from[key], into[key]);
}
}
return result;
}
}
{
"name": "@canvas-js/utils",
"version": "0.11.0",
"version": "0.13.0-next.1",
"author": "Canvas Technologies, Inc. (https://canvas.xyz)",

@@ -19,4 +19,4 @@ "type": "module",

"dependencies": {
"@canvas-js/interfaces": "0.11.0"
"@canvas-js/interfaces": "0.13.0-next.1"
}
}
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