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

@opencreek/ext

Package Overview
Dependencies
Maintainers
4
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opencreek/ext - npm Package Compare versions

Comparing version 2.0.1--canary.25.5741241930.0 to 2.0.1--canary.25.5748379176.0

12

build/collections.d.ts

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

declare type PairSplit<T> = T extends [infer F, infer L] ? [Chain<F>, Chain<L>] : never;
declare type IfString<T, U> = T extends string ? U : never;
declare type FlattenChain<T> = T extends Chain<infer U> ? Chain<U> : T extends Array<infer U> ? Chain<U> : never;
type PairSplit<T> = T extends [infer F, infer L] ? [Chain<F>, Chain<L>] : never;
type IfString<T, U> = T extends string ? U : never;
type ArrayOrChain<U> = Chain<U> | ReadonlyArray<U>;
type Distribute<U> = U extends any ? {
type: U;
} : never;
type FlattenChain<T> = Distribute<T> extends {
type: ArrayOrChain<infer U>;
} ? Chain<U> : Chain<T>;
export declare function objChain<K extends string | number | symbol, T>(value: Record<K, T> | ObjectChain<K, T> | Chain<readonly [K, T]>): ObjectChain<K, T>;

@@ -5,0 +11,0 @@ export declare function objChain<_K extends string | number | symbol, _T>(value: undefined | null): undefined;

@@ -190,3 +190,3 @@ "use strict";

flatten() {
const flattened = this.val.flatMap((it) => it instanceof Chain ? it.val : it);
const flattened = this.val.flatMap((it) => it instanceof Chain ? it.val : Array.isArray(it) ? it : [it]);
return new Chain(flattened);

@@ -193,0 +193,0 @@ }

@@ -111,5 +111,11 @@ "use strict";

const result = (0, collections_1.chain)(arr).flatten().writableValue();
t.is(result.length, 3);
t.deepEqual(result, [1, 2, 3]);
});
(0, ava_1.default)("should allow flattening on mixed Chains", (t) => {
const arr = [[1], (0, collections_1.chain)([2, 3]), 4, { foo: 5 }];
const chainIn = (0, collections_1.chain)(arr);
const flattened = chainIn.flatten();
const result = flattened.writableValue();
t.deepEqual(result, [1, 2, 3, 4, { foo: 5 }]);
});
//# sourceMappingURL=collections.test.js.map
export declare function extendProtoype(target: Function, func: Function, functionName: string): void;
export declare function extendPrototypeWithName<T extends Record<string, Function>>(target: Function, wrap: T): void;
declare type ThisFunction<F extends (...args: any) => any> = (this: FirstParameter<F>, ...args: SkipFirstParameter<F>) => ReturnType<F>;
declare type FirstParameter<F extends (...args: any) => any> = Parameters<F> extends [
type ThisFunction<F extends (...args: any) => any> = (this: FirstParameter<F>, ...args: SkipFirstParameter<F>) => ReturnType<F>;
type FirstParameter<F extends (...args: any) => any> = Parameters<F> extends [
infer T,
...infer _
] ? T : never;
declare type SkipFirst<T extends unknown[]> = T extends [infer _, ...infer R] ? [...R] : never;
declare type SkipFirstParameter<F extends (...args: any) => any> = SkipFirst<Parameters<F>>;
type SkipFirst<T extends unknown[]> = T extends [infer _, ...infer R] ? [...R] : never;
type SkipFirstParameter<F extends (...args: any) => any> = SkipFirst<Parameters<F>>;
export declare function apply<F extends (...args: any) => any>(f: F): ThisFunction<F>;
export {};
//# sourceMappingURL=extendPrototype.d.ts.map
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

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

declare type Task = {
type Task = {
name: string;

@@ -3,0 +3,0 @@ start: number;

{
"name": "@opencreek/ext",
"version": "2.0.1--canary.25.5741241930.0",
"version": "2.0.1--canary.25.5748379176.0",
"description": "",

@@ -35,3 +35,3 @@ "main": "build/index.js",

"prettier": "^2.4.1",
"typescript": "^4.4.3"
"typescript": "5.1.6"
},

@@ -38,0 +38,0 @@ "prettier": {

@@ -131,4 +131,12 @@ import test from "ava"

t.is(result.length, 3)
t.deepEqual(result, [1, 2, 3])
})
test("should allow flattening on mixed Chains", (t) => {
const arr = [[1], chain([2, 3]), 4, { foo: 5 }]
const chainIn = chain(arr)
const flattened = chainIn.flatten()
const result = flattened.writableValue()
t.deepEqual(result, [1, 2, 3, 4, { foo: 5 }])
})

@@ -36,7 +36,10 @@ import {

type IfString<T, U> = T extends string ? U : never
type FlattenChain<T> = T extends Chain<infer U>
type ArrayOrChain<U> = Chain<U> | ReadonlyArray<U>
// used to mappe type union below
// otherwise mixed types in chains, would not be carried over correctly
type Distribute<U> = U extends any ? { type: U } : never
type FlattenChain<T> = Distribute<T> extends { type: ArrayOrChain<infer U> }
? Chain<U>
: T extends Array<infer U>
? Chain<U>
: never
: Chain<T>

@@ -326,3 +329,3 @@ export function objChain<K extends string | number | symbol, T>(

const flattened = this.val.flatMap((it) =>
it instanceof Chain ? it.val : it
it instanceof Chain ? it.val : Array.isArray(it) ? it : [it]
)

@@ -329,0 +332,0 @@ return new Chain(flattened) as FlattenChain<T>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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