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

@kaciras/utilities

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kaciras/utilities - npm Package Compare versions

Comparing version 0.10.4 to 0.11.0

20

lib/browser.js

@@ -46,3 +46,3 @@ const alwaysTrue = ()=>true;

/**
* Get the first item of the iterable object, or undefined it's empty.
* Get the first item of the iterable object, or undefined if it's empty.
*

@@ -133,2 +133,4 @@ * NOTE: Code after the first yield in Generator will not be executed.

*
* NOTE: properties with symbol keys are ignored if the src is an object.
*
* @example

@@ -147,4 +149,10 @@ * cartesianObject({

* { a: 1, b: 2, c: 5 }
* // Also support for entries, the following returns same result:
* cartesianObject([
* ["a", [0, 1]],
* ["b", [2]],
* ["c", new Set([3, 4, 5])],
* ]);
*/ function cartesianObject(src) {
const entries = Object.entries(src);
const entries = Array.isArray(src) ? src : Object.entries(src);
const temp = {};

@@ -499,3 +507,3 @@ function* recursive(index) {

* set to zero or negative value to disable timeout.
*/ function pubSub2ReqRes(publish, timeout = 10e3) {
*/ function pubSub2ReqRes(publish, timeout = 0) {
const txMap = new Map();

@@ -536,3 +544,3 @@ function receive(message) {

txMap.delete(sessionId);
tx.reject(new Error("Timed out"));
tx.reject(new Error("Receiving message timed out"));
}

@@ -754,6 +762,6 @@ }

/**
* Convert between bytes and human-readable string using SI prefixes.
* Convert between bytes and human-readable string using SI (1000) prefixes.
*/ const dataSizeSI = new UnitConvertor("data size", SIZE_UNITS, SIZE_FRACTIONS_SI);
/**
* Convert between bytes and human-readable string using IEC prefixes.
* Convert between bytes and human-readable string using IEC (1024) prefixes.
*/ const dataSizeIEC = new UnitConvertor("data size", SIZE_UNITS, SIZE_FRACTIONS_IEC);

@@ -760,0 +768,0 @@ /**

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

import { ItemOfIterable } from "./lang.js";
import { ItemOfIterable, UnionToIntersection } from "./lang.js";
/**
* Get the first item of the iterable object, or undefined it's empty.
* Get the first item of the iterable object, or undefined if it's empty.
*

@@ -61,8 +61,20 @@ * NOTE: Code after the first yield in Generator will not be executed.

export type CPSrcObject = Record<string, Iterable<unknown>>;
export type CPCellObject<T extends CPSrcObject> = {
-readonly [K in keyof T]: ItemOfIterable<T[K]>;
export type CPSrcEntries = ReadonlyArray<readonly [string, Iterable<unknown>]>;
type CPObjectInput = CPSrcObject | CPSrcEntries;
type Merge<T> = unknown & {
[P in keyof T]: T[P];
};
type CPCellObject<T extends CPSrcObject> = {
-readonly [K in Exclude<keyof T, symbol>]: ItemOfIterable<T[K]>;
};
type FromEntries<T> = T extends ReadonlyArray<infer E> ? E extends readonly [infer K, infer V] ? {
[P in Extract<K, string>]: ItemOfIterable<V>;
} : never : never;
type CPCellEntries<T> = Merge<UnionToIntersection<FromEntries<T>>>;
export type CartesianObjectCell<T extends CPObjectInput> = T extends CPSrcObject ? CPCellObject<T> : CPCellEntries<T>;
/**
* Get the cartesian product generator of objects.
*
* NOTE: properties with symbol keys are ignored if the src is an object.
*
* @example

@@ -81,7 +93,13 @@ * cartesianObject({

* { a: 1, b: 2, c: 5 }
* // Also support for entries, the following returns same result:
* cartesianObject([
* ["a", [0, 1]],
* ["b", [2]],
* ["c", new Set([3, 4, 5])],
* ]);
*/
export declare function cartesianObject<const T extends CPSrcObject>(src: T): Iterable<CPCellObject<T>>;
export type CPSrcArray = ReadonlyArray<Iterable<unknown>>;
type CastArray<T extends CPSrcArray> = T extends readonly [infer E, ...infer REST] ? REST extends CPSrcArray ? [ItemOfIterable<E>, ...CastArray<REST>] : never : T;
export type CPCellArray<T extends CPSrcArray> = T extends readonly [any, ...any[]] ? CastArray<T> : T[number];
export declare function cartesianObject<const T extends CPObjectInput>(src: T): Iterable<CartesianObjectCell<T>>;
export type CPArrayInput = ReadonlyArray<Iterable<unknown>>;
type CastArray<T extends CPArrayInput> = T extends readonly [infer E, ...infer REST] ? REST extends CPArrayInput ? [ItemOfIterable<E>, ...CastArray<REST>] : never : T;
export type CartesianArrayCell<T extends CPArrayInput> = T extends readonly [any, ...any[]] ? CastArray<T> : T[number];
/**

@@ -108,3 +126,3 @@ * Get the cartesian product generator of multiple arrays.

*/
export declare function cartesianArray<const T extends CPSrcArray>(src: T): Iterable<CPCellArray<T>>;
export declare function cartesianArray<const T extends CPArrayInput>(src: T): Iterable<CartesianArrayCell<T>>;
export {};

@@ -84,7 +84,7 @@ export declare class UnitConvertor<T extends readonly string[]> {

/**
* Convert between bytes and human-readable string using SI prefixes.
* Convert between bytes and human-readable string using SI (1000) prefixes.
*/
export declare const dataSizeSI: UnitConvertor<readonly ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]>;
/**
* Convert between bytes and human-readable string using IEC prefixes.
* Convert between bytes and human-readable string using IEC (1024) prefixes.
*/

@@ -91,0 +91,0 @@ export declare const dataSizeIEC: UnitConvertor<readonly ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]>;

@@ -5,2 +5,3 @@ export type ItemOfIterable<T> = T extends Iterable<infer E> ? E : never;

export type OnRejected<R> = ((reason: any) => R | PromiseLike<R>) | null;
export type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends ((x: infer I) => void) ? I : never;
export declare const alwaysTrue: (..._: unknown[]) => true;

@@ -7,0 +8,0 @@ export declare const alwaysFalse: (..._: unknown[]) => false;

@@ -48,3 +48,3 @@ import process from 'process';

/**
* Get the first item of the iterable object, or undefined it's empty.
* Get the first item of the iterable object, or undefined if it's empty.
*

@@ -135,2 +135,4 @@ * NOTE: Code after the first yield in Generator will not be executed.

*
* NOTE: properties with symbol keys are ignored if the src is an object.
*
* @example

@@ -149,4 +151,10 @@ * cartesianObject({

* { a: 1, b: 2, c: 5 }
* // Also support for entries, the following returns same result:
* cartesianObject([
* ["a", [0, 1]],
* ["b", [2]],
* ["c", new Set([3, 4, 5])],
* ]);
*/ function cartesianObject(src) {
const entries = Object.entries(src);
const entries = Array.isArray(src) ? src : Object.entries(src);
const temp = {};

@@ -497,3 +505,3 @@ function* recursive(index) {

* set to zero or negative value to disable timeout.
*/ function pubSub2ReqRes(publish, timeout = 10e3) {
*/ function pubSub2ReqRes(publish, timeout = 0) {
const txMap = new Map();

@@ -537,3 +545,3 @@ function receive(message) {

txMap.delete(sessionId);
tx.reject(new Error("Timed out"));
tx.reject(new Error("Receiving message timed out"));
}

@@ -938,6 +946,6 @@ }

/**
* Convert between bytes and human-readable string using SI prefixes.
* Convert between bytes and human-readable string using SI (1000) prefixes.
*/ const dataSizeSI = new UnitConvertor("data size", SIZE_UNITS, SIZE_FRACTIONS_SI);
/**
* Convert between bytes and human-readable string using IEC prefixes.
* Convert between bytes and human-readable string using IEC (1024) prefixes.
*/ const dataSizeIEC = new UnitConvertor("data size", SIZE_UNITS, SIZE_FRACTIONS_IEC);

@@ -944,0 +952,0 @@ /**

{
"name": "@kaciras/utilities",
"version": "0.10.4",
"version": "0.11.0",
"license": "MIT",

@@ -27,5 +27,5 @@ "description": "A set of common JS functions for node and browser.",

"@jest/globals": "^29.7.0",
"@kaciras/eslint-config-core": "^2.6.1",
"@kaciras/eslint-config-jest": "^2.6.1",
"@kaciras/eslint-config-typescript": "^2.6.2",
"@kaciras/eslint-config-core": "^2.6.3",
"@kaciras/eslint-config-jest": "^2.6.3",
"@kaciras/eslint-config-typescript": "^2.6.3",
"@playwright/test": "^1.40.1",

@@ -35,3 +35,3 @@ "@rollup/plugin-replace": "^5.0.5",

"@stryker-mutator/jest-runner": "^8.0.0",
"@swc/core": "^1.3.101",
"@swc/core": "^1.3.102",
"@swc/jest": "^0.2.29",

@@ -42,3 +42,3 @@ "@tsd/typescript": "^5.3.3",

"@types/istanbul-reports": "^3.0.4",
"@types/node": "^20.10.5",
"@types/node": "^20.10.6",
"es-module-lexer": "^1.4.1",

@@ -53,4 +53,4 @@ "eslint": "^8.56.0",

"mockttp": "^3.10.0",
"rollup": "^4.9.1",
"tsd-lite": "^0.8.1",
"rollup": "^4.9.2",
"tsd-lite": "^0.8.2",
"typescript": "^5.3.3",

@@ -57,0 +57,0 @@ "v8-to-istanbul": "^9.2.0"

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