Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

space-lift

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

space-lift - npm Package Compare versions

Comparing version 1.0.0-beta.7 to 1.0.0-beta.8

15

commonjs/array.d.ts

@@ -12,3 +12,6 @@ import { Draft } from './immupdate';

value(): T;
clone(): ArrayWrapper<unknown[]>;
/**
* Shallowly clones this Array.
*/
clone(): ArrayWrapper<T>;
private _clone;

@@ -73,4 +76,4 @@ /**

*/
flatten<A>(this: ArrayWrapper<ReadonlyArray<A>>): ArrayWrapper<ArrayOf<T, A>>;
flatten<A>(this: ArrayWrapper<A[]>): ArrayWrapper<ArrayOf<T, A>>;
flatten<A>(this: ArrayWrapper<ReadonlyArray<ReadonlyArray<A>>>): ArrayWrapper<ArrayOf<T, A>>;
flatten<A>(this: ArrayWrapper<A[][]>): ArrayWrapper<ArrayOf<T, A>>;
/**

@@ -88,3 +91,3 @@ * Folds this Array into a single value, using a starting value.

*/
groupBy<K extends string | number>(discriminator: (item: T[number], index: number) => K): MapWrapper<K, T>;
groupBy<K extends string | number>(discriminator: (item: T[number], index: number) => K): MapWrapper<K, T, MapFromArray<T, K, T>>;
/**

@@ -127,3 +130,3 @@ * Inserts an item at a specified index.

*/
toSet(): SetWrapper<T[number]>;
toSet(): SetWrapper<T[number], SetFromArray<T>>;
/**

@@ -151,3 +154,5 @@ * Make mutable modifications to a draft then return a new Array.

declare type Compacted<T> = T extends null | undefined | 0 | false ? never : T;
declare type SetFromArray<T extends ReadonlyArray<unknown>> = T extends Array<infer E> ? Set<E> : T extends ReadonlyArray<infer E> ? ReadonlySet<E> : never;
declare type ArrayOf<T extends ReadonlyArray<unknown>, ITEM> = T extends Array<any> ? Array<ITEM> : ReadonlyArray<ITEM>;
declare type MapFromArray<T extends ReadonlyArray<unknown>, K, V> = T extends Array<any> ? Map<K, V> : ReadonlyMap<K, V>;
export {};

@@ -21,2 +21,5 @@ "use strict";

}
/**
* Shallowly clones this Array.
*/
clone() {

@@ -23,0 +26,0 @@ return new ArrayWrapper(this._clone());

@@ -9,1 +9,10 @@ export { lift } from './lift';

export declare const is: typeof isType;
export declare function immutable<T>(obj: T): Immutable<T>;
export declare type Immutable<T> = T extends ImmutablePrimitive ? T : T extends Array<infer U> ? ImmutableArray<U> : T extends Map<infer K, infer V> ? ImmutableMap<K, V> : T extends Set<infer M> ? ImmutableSet<M> : ImmutableObject<T>;
declare type ImmutablePrimitive = undefined | null | boolean | string | number | Function;
declare type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
declare type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
declare type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
declare type ImmutableObject<T> = {
readonly [K in keyof T]: Immutable<T[K]>;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.is = exports.noop = exports.identity = exports.createEnum = exports.createUnion = exports.range = exports.update = exports.lift = void 0;
exports.immutable = exports.is = exports.noop = exports.identity = exports.createEnum = exports.createUnion = exports.range = exports.update = exports.lift = void 0;
const lift_1 = require("./lift");

@@ -28,1 +28,5 @@ var lift_2 = require("./lift");

set_1.setSetPipe(lift_1.pipe);
function immutable(obj) {
return obj;
}
exports.immutable = immutable;

@@ -8,8 +8,8 @@ import { ArrayWrapper } from './array';

declare type AtomicObject = Function | Promise<any> | Date | RegExp | Boolean | Number | String;
declare type LiftedValue<T> = null extends T ? never : undefined extends T ? never : T extends AtomicObject ? T : T extends ReadonlyArray<any> ? ArrayWrapper<T> : T extends ReadonlyMap<infer K, infer V> ? MapWrapper<K, V> : T extends ReadonlySet<infer E> ? SetWrapper<E> : T extends object ? ObjectWrapper<T> : never;
declare type LiftedValue<T> = null extends T ? never : undefined extends T ? never : T extends AtomicObject ? T : T extends ReadonlyArray<any> ? ArrayWrapper<T> : T extends ReadonlyMap<infer K, infer V> ? MapWrapper<K, V, T> : T extends ReadonlySet<infer E> ? SetWrapper<E, T> : T extends object ? ObjectWrapper<T> : never;
interface Lift {
<T>(obj: ArrayWrapper<ReadonlyArray<T>>): ArrayWrapper<ReadonlyArray<T>>;
<T extends object>(obj: ObjectWrapper<T>): ObjectWrapper<T>;
<K, V>(obj: MapWrapper<K, V>): MapWrapper<K, V>;
<T>(obj: SetWrapper<T>): SetWrapper<T>;
<K, V, M extends ReadonlyMap<K, V>>(obj: MapWrapper<K, V, M>): MapWrapper<K, V, M>;
<T, S extends ReadonlySet<T>>(obj: SetWrapper<T, S>): SetWrapper<T, S>;
/** lift won't wrap primitives and some other non container-like objects */

@@ -19,7 +19,12 @@ <T extends AtomicObject>(obj: T): T;

<T>(obj: T[]): ArrayWrapper<T[]>;
/** Wraps a readonly Array to provide a richer API. Unwrap with .value() **/
<T>(obj: ReadonlyArray<T>): ArrayWrapper<ReadonlyArray<T>>;
/** Wraps a Map to provide a richer API. Unwrap with .value() **/
<K, V>(obj: Map<K, V>): MapWrapper<K, V, Map<K, V>>;
/** Wraps a readonly Map to provide a richer API. Unwrap with .value() **/
<K, V>(obj: ReadonlyMap<K, V>): MapWrapper<K, V, ReadonlyMap<K, V>>;
/** Wraps a Set to provide a richer API. Unwrap with .value() **/
<T>(obj: ReadonlySet<T>): SetWrapper<T>;
/** Wraps a Map to provide a richer API. Unwrap with .value() **/
<K, V>(obj: ReadonlyMap<K, V>): MapWrapper<K, V>;
<T>(obj: Set<T>): SetWrapper<T, Set<T>>;
/** Wraps a readonly Set to provide a richer API. Unwrap with .value() **/
<T>(obj: ReadonlySet<T>): SetWrapper<T, ReadonlySet<T>>;
/** Wraps an Object to provide a richer API. Unwrap with .value() **/

@@ -26,0 +31,0 @@ <T extends object>(obj: T): ObjectWrapper<T>;

import { Draft } from './immupdate';
import type { Pipe } from './lift';
/** A Map wrapper providing extra functionalities and more chaining opportunities */
export declare class MapWrapper<K, V> {
export declare class MapWrapper<K, V, M extends ReadonlyMap<K, V>> {
private _value;
constructor(_value: ReadonlyMap<K, V>);
constructor(_value: M);
private _isLiftWrapper;
value(): ReadonlyMap<K, V>;
clone(): MapWrapper<K, V>;
value(): M;
clone(): MapWrapper<K, V, M>;
private _clone;

@@ -14,31 +14,31 @@ /**

*/
set(key: K, value: V): MapWrapper<K, V>;
set(key: K, value: V): MapWrapper<unknown, unknown, Map<K, V>>;
/**
* Deletes a key/value.
*/
delete(key: K): MapWrapper<K, V>;
delete(key: K): MapWrapper<unknown, unknown, Map<K, V>>;
/**
* Clears the map.
*/
clear(): MapWrapper<K, V>;
clear(): MapWrapper<unknown, unknown, Map<K, V>>;
/**
* Maps this Map's keys and values, unless void or undefined is returned, in which case the entry is filtered.
*/
collect<KK, VV>(iterator: (key: K, value: V) => [KK, VV] | undefined | void): MapWrapper<KK, VV>;
collect<KK, VV>(iterator: (key: K, value: V) => [KK, VV] | undefined | void): MapWrapper<KK, VV, MapOf<M, KK, VV>>;
/**
* Filters this Map's keys and values by aplying a predicate to all values and refine its type.
*/
filter<VV extends V>(predicate: (key: K, value: V) => value is VV): MapWrapper<K, VV>;
filter<VV extends V>(predicate: (key: K, value: V) => value is VV): MapWrapper<K, VV, MapOf<M, K, VV>>;
/**
* Filters this Map's keys and values.
*/
filter(predicate: (key: K, value: V) => boolean): MapWrapper<K, V>;
filter(predicate: (key: K, value: V) => boolean): this;
/**
* Maps this map's value.
*/
mapValues<VV>(mapFunction: (value: V) => VV): MapWrapper<K, VV>;
mapValues<VV>(mapFunction: (value: V) => VV): MapWrapper<K, VV, MapOf<M, K, VV>>;
/**
* Make mutable modifications to a draft then return a new Map.
*/
update(updateFunction: (draft: Draft<ReadonlyMap<K, V>>) => void): MapWrapper<K, V>;
update(updateFunction: (draft: Draft<ReadonlyMap<K, V>>) => void): import("./lift").Lifted<M>;
pipe: typeof import("./lift").pipe;

@@ -48,1 +48,3 @@ toArray(): import("./array").ArrayWrapper<[K, V][]>;

export declare function setMapPipe(_pipe: Pipe): void;
declare type MapOf<T extends ReadonlyMap<unknown, unknown>, K, V> = T extends Map<any, any> ? Map<K, V> : ReadonlyMap<K, V>;
export {};

@@ -9,3 +9,3 @@ import { ArrayWrapper } from './array';

value(): T;
clone(): ObjectWrapper<any>;
clone(): ObjectWrapper<T>;
private _clone;

@@ -12,0 +12,0 @@ /**

import type { Pipe } from './lift';
/** A Set wrapper providing extra functionalities and more chaining opportunities */
export declare class SetWrapper<T> {
export declare class SetWrapper<T, S extends ReadonlySet<T>> {
private _value;
constructor(_value: ReadonlySet<T>);
constructor(_value: S);
private _isLiftWrapper;
value(): ReadonlySet<T>;
clone(): SetWrapper<T>;
value(): S;
clone(): SetWrapper<T, S>;
private _clone;
add(item: T): SetWrapper<T>;
delete(item: T): SetWrapper<T>;
clear(): SetWrapper<T>;
collect<B>(iterator: (item: T) => B | void | undefined): SetWrapper<B>;
add(item: T): this;
delete(item: T): this;
clear(): this;
collect<B>(iterator: (item: T) => B | void | undefined): SetWrapper<B, SetOf<S, B>>;
/**
* Filters this Set's items by aplying a predicate to all values and refine its type.
*/
filter<B extends T>(predicate: (item: T) => item is B): SetWrapper<B>;
filter<B extends T>(predicate: (item: T) => item is B): SetWrapper<B, SetOf<S, B>>;
/**
* Filters this Set's items.
*/
filter(predicate: (item: T) => boolean): SetWrapper<T>;
filter(predicate: (item: T) => boolean): SetWrapper<T, S>;
toArray(): import("./array").ArrayWrapper<T[]>;

@@ -26,1 +26,3 @@ pipe: typeof import("./lift").pipe;

export declare function setSetPipe(_pipe: Pipe): void;
declare type SetOf<T extends ReadonlySet<unknown>, ITEM> = T extends Set<any> ? Set<ITEM> : ReadonlySet<ITEM>;
export {};

@@ -12,3 +12,6 @@ import { Draft } from './immupdate';

value(): T;
clone(): ArrayWrapper<unknown[]>;
/**
* Shallowly clones this Array.
*/
clone(): ArrayWrapper<T>;
private _clone;

@@ -73,4 +76,4 @@ /**

*/
flatten<A>(this: ArrayWrapper<ReadonlyArray<A>>): ArrayWrapper<ArrayOf<T, A>>;
flatten<A>(this: ArrayWrapper<A[]>): ArrayWrapper<ArrayOf<T, A>>;
flatten<A>(this: ArrayWrapper<ReadonlyArray<ReadonlyArray<A>>>): ArrayWrapper<ArrayOf<T, A>>;
flatten<A>(this: ArrayWrapper<A[][]>): ArrayWrapper<ArrayOf<T, A>>;
/**

@@ -88,3 +91,3 @@ * Folds this Array into a single value, using a starting value.

*/
groupBy<K extends string | number>(discriminator: (item: T[number], index: number) => K): MapWrapper<K, T>;
groupBy<K extends string | number>(discriminator: (item: T[number], index: number) => K): MapWrapper<K, T, MapFromArray<T, K, T>>;
/**

@@ -127,3 +130,3 @@ * Inserts an item at a specified index.

*/
toSet(): SetWrapper<T[number]>;
toSet(): SetWrapper<T[number], SetFromArray<T>>;
/**

@@ -151,3 +154,5 @@ * Make mutable modifications to a draft then return a new Array.

declare type Compacted<T> = T extends null | undefined | 0 | false ? never : T;
declare type SetFromArray<T extends ReadonlyArray<unknown>> = T extends Array<infer E> ? Set<E> : T extends ReadonlyArray<infer E> ? ReadonlySet<E> : never;
declare type ArrayOf<T extends ReadonlyArray<unknown>, ITEM> = T extends Array<any> ? Array<ITEM> : ReadonlyArray<ITEM>;
declare type MapFromArray<T extends ReadonlyArray<unknown>, K, V> = T extends Array<any> ? Map<K, V> : ReadonlyMap<K, V>;
export {};

@@ -18,2 +18,5 @@ import { identity } from './function';

}
/**
* Shallowly clones this Array.
*/
clone() {

@@ -20,0 +23,0 @@ return new ArrayWrapper(this._clone());

@@ -9,1 +9,10 @@ export { lift } from './lift';

export declare const is: typeof isType;
export declare function immutable<T>(obj: T): Immutable<T>;
export declare type Immutable<T> = T extends ImmutablePrimitive ? T : T extends Array<infer U> ? ImmutableArray<U> : T extends Map<infer K, infer V> ? ImmutableMap<K, V> : T extends Set<infer M> ? ImmutableSet<M> : ImmutableObject<T>;
declare type ImmutablePrimitive = undefined | null | boolean | string | number | Function;
declare type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
declare type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
declare type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
declare type ImmutableObject<T> = {
readonly [K in keyof T]: Immutable<T[K]>;
};

@@ -18,1 +18,4 @@ import { pipe } from './lift';

setSetPipe(pipe);
export function immutable(obj) {
return obj;
}

@@ -8,8 +8,8 @@ import { ArrayWrapper } from './array';

declare type AtomicObject = Function | Promise<any> | Date | RegExp | Boolean | Number | String;
declare type LiftedValue<T> = null extends T ? never : undefined extends T ? never : T extends AtomicObject ? T : T extends ReadonlyArray<any> ? ArrayWrapper<T> : T extends ReadonlyMap<infer K, infer V> ? MapWrapper<K, V> : T extends ReadonlySet<infer E> ? SetWrapper<E> : T extends object ? ObjectWrapper<T> : never;
declare type LiftedValue<T> = null extends T ? never : undefined extends T ? never : T extends AtomicObject ? T : T extends ReadonlyArray<any> ? ArrayWrapper<T> : T extends ReadonlyMap<infer K, infer V> ? MapWrapper<K, V, T> : T extends ReadonlySet<infer E> ? SetWrapper<E, T> : T extends object ? ObjectWrapper<T> : never;
interface Lift {
<T>(obj: ArrayWrapper<ReadonlyArray<T>>): ArrayWrapper<ReadonlyArray<T>>;
<T extends object>(obj: ObjectWrapper<T>): ObjectWrapper<T>;
<K, V>(obj: MapWrapper<K, V>): MapWrapper<K, V>;
<T>(obj: SetWrapper<T>): SetWrapper<T>;
<K, V, M extends ReadonlyMap<K, V>>(obj: MapWrapper<K, V, M>): MapWrapper<K, V, M>;
<T, S extends ReadonlySet<T>>(obj: SetWrapper<T, S>): SetWrapper<T, S>;
/** lift won't wrap primitives and some other non container-like objects */

@@ -19,7 +19,12 @@ <T extends AtomicObject>(obj: T): T;

<T>(obj: T[]): ArrayWrapper<T[]>;
/** Wraps a readonly Array to provide a richer API. Unwrap with .value() **/
<T>(obj: ReadonlyArray<T>): ArrayWrapper<ReadonlyArray<T>>;
/** Wraps a Map to provide a richer API. Unwrap with .value() **/
<K, V>(obj: Map<K, V>): MapWrapper<K, V, Map<K, V>>;
/** Wraps a readonly Map to provide a richer API. Unwrap with .value() **/
<K, V>(obj: ReadonlyMap<K, V>): MapWrapper<K, V, ReadonlyMap<K, V>>;
/** Wraps a Set to provide a richer API. Unwrap with .value() **/
<T>(obj: ReadonlySet<T>): SetWrapper<T>;
/** Wraps a Map to provide a richer API. Unwrap with .value() **/
<K, V>(obj: ReadonlyMap<K, V>): MapWrapper<K, V>;
<T>(obj: Set<T>): SetWrapper<T, Set<T>>;
/** Wraps a readonly Set to provide a richer API. Unwrap with .value() **/
<T>(obj: ReadonlySet<T>): SetWrapper<T, ReadonlySet<T>>;
/** Wraps an Object to provide a richer API. Unwrap with .value() **/

@@ -26,0 +31,0 @@ <T extends object>(obj: T): ObjectWrapper<T>;

import { Draft } from './immupdate';
import type { Pipe } from './lift';
/** A Map wrapper providing extra functionalities and more chaining opportunities */
export declare class MapWrapper<K, V> {
export declare class MapWrapper<K, V, M extends ReadonlyMap<K, V>> {
private _value;
constructor(_value: ReadonlyMap<K, V>);
constructor(_value: M);
private _isLiftWrapper;
value(): ReadonlyMap<K, V>;
clone(): MapWrapper<K, V>;
value(): M;
clone(): MapWrapper<K, V, M>;
private _clone;

@@ -14,31 +14,31 @@ /**

*/
set(key: K, value: V): MapWrapper<K, V>;
set(key: K, value: V): MapWrapper<unknown, unknown, Map<K, V>>;
/**
* Deletes a key/value.
*/
delete(key: K): MapWrapper<K, V>;
delete(key: K): MapWrapper<unknown, unknown, Map<K, V>>;
/**
* Clears the map.
*/
clear(): MapWrapper<K, V>;
clear(): MapWrapper<unknown, unknown, Map<K, V>>;
/**
* Maps this Map's keys and values, unless void or undefined is returned, in which case the entry is filtered.
*/
collect<KK, VV>(iterator: (key: K, value: V) => [KK, VV] | undefined | void): MapWrapper<KK, VV>;
collect<KK, VV>(iterator: (key: K, value: V) => [KK, VV] | undefined | void): MapWrapper<KK, VV, MapOf<M, KK, VV>>;
/**
* Filters this Map's keys and values by aplying a predicate to all values and refine its type.
*/
filter<VV extends V>(predicate: (key: K, value: V) => value is VV): MapWrapper<K, VV>;
filter<VV extends V>(predicate: (key: K, value: V) => value is VV): MapWrapper<K, VV, MapOf<M, K, VV>>;
/**
* Filters this Map's keys and values.
*/
filter(predicate: (key: K, value: V) => boolean): MapWrapper<K, V>;
filter(predicate: (key: K, value: V) => boolean): this;
/**
* Maps this map's value.
*/
mapValues<VV>(mapFunction: (value: V) => VV): MapWrapper<K, VV>;
mapValues<VV>(mapFunction: (value: V) => VV): MapWrapper<K, VV, MapOf<M, K, VV>>;
/**
* Make mutable modifications to a draft then return a new Map.
*/
update(updateFunction: (draft: Draft<ReadonlyMap<K, V>>) => void): MapWrapper<K, V>;
update(updateFunction: (draft: Draft<ReadonlyMap<K, V>>) => void): import("./lift").Lifted<M>;
pipe: typeof import("./lift").pipe;

@@ -48,1 +48,3 @@ toArray(): import("./array").ArrayWrapper<[K, V][]>;

export declare function setMapPipe(_pipe: Pipe): void;
declare type MapOf<T extends ReadonlyMap<unknown, unknown>, K, V> = T extends Map<any, any> ? Map<K, V> : ReadonlyMap<K, V>;
export {};

@@ -9,3 +9,3 @@ import { ArrayWrapper } from './array';

value(): T;
clone(): ObjectWrapper<any>;
clone(): ObjectWrapper<T>;
private _clone;

@@ -12,0 +12,0 @@ /**

import type { Pipe } from './lift';
/** A Set wrapper providing extra functionalities and more chaining opportunities */
export declare class SetWrapper<T> {
export declare class SetWrapper<T, S extends ReadonlySet<T>> {
private _value;
constructor(_value: ReadonlySet<T>);
constructor(_value: S);
private _isLiftWrapper;
value(): ReadonlySet<T>;
clone(): SetWrapper<T>;
value(): S;
clone(): SetWrapper<T, S>;
private _clone;
add(item: T): SetWrapper<T>;
delete(item: T): SetWrapper<T>;
clear(): SetWrapper<T>;
collect<B>(iterator: (item: T) => B | void | undefined): SetWrapper<B>;
add(item: T): this;
delete(item: T): this;
clear(): this;
collect<B>(iterator: (item: T) => B | void | undefined): SetWrapper<B, SetOf<S, B>>;
/**
* Filters this Set's items by aplying a predicate to all values and refine its type.
*/
filter<B extends T>(predicate: (item: T) => item is B): SetWrapper<B>;
filter<B extends T>(predicate: (item: T) => item is B): SetWrapper<B, SetOf<S, B>>;
/**
* Filters this Set's items.
*/
filter(predicate: (item: T) => boolean): SetWrapper<T>;
filter(predicate: (item: T) => boolean): SetWrapper<T, S>;
toArray(): import("./array").ArrayWrapper<T[]>;

@@ -26,1 +26,3 @@ pipe: typeof import("./lift").pipe;

export declare function setSetPipe(_pipe: Pipe): void;
declare type SetOf<T extends ReadonlySet<unknown>, ITEM> = T extends Set<any> ? Set<ITEM> : ReadonlySet<ITEM>;
export {};
{
"name": "space-lift",
"version": "1.0.0-beta.7",
"description": "Idiomatic Typescript Array, Object, Map, Set, Union, Enum utils",
"version": "1.0.0-beta.8",
"description": "Idiomatic TypeScript Array, Object, Map, Set, Union, Enum utils",
"sideEffects": true,

@@ -6,0 +6,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