New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@strut/utils

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@strut/utils - npm Package Compare versions

Comparing version
0.0.11
to
0.1.0
+11
src/applyMixins.ts
export default function applyMixins(derivedCtor: any, mixins: any[]) {
mixins.forEach((mixin) => {
Object.getOwnPropertyNames(mixin).forEach((name) => {
Object.defineProperty(
derivedCtor.prototype,
name,
Object.getOwnPropertyDescriptor(mixin, name) || Object.create(null)
);
});
});
}
+1
-1
{
"name": "@strut/utils",
"version": "0.0.11",
"version": "0.1.0",
"main": "lib/index.js",

@@ -5,0 +5,0 @@ "type": "module",

@@ -1,18 +0,19 @@

import invariant from './invariant.js';
import * as math from './math.js';
import notEmpty from './notEmpty.js';
import nullthrows from './nullthrows.js';
import typedKeys from './typedKeys_UNSAFE.js';
import memoize from './memoize.js';
import asString from './asString.js';
import debounce from './debounce.js';
import keyById from './keyById.js';
import readAndParse from './readAndParse.js';
import stripSuffix from './stripSuffix.js';
import select from './select.js';
import upcaseAt from './upcaseAt.js';
import { lowercaseAt } from './upcaseAt.js';
import assertUnreachable from './assertUnreachable.js';
import only from './only.js';
import maybeMap from './maybeMap.js';
import invariant from "./invariant.js";
import * as math from "./math.js";
import notEmpty from "./notEmpty.js";
import nullthrows from "./nullthrows.js";
import typedKeys from "./typedKeys_UNSAFE.js";
import memoize from "./memoize.js";
import asString from "./asString.js";
import debounce from "./debounce.js";
import keyById from "./keyById.js";
import readAndParse from "./readAndParse.js";
import stripSuffix from "./stripSuffix.js";
import select from "./select.js";
import upcaseAt from "./upcaseAt.js";
import { lowercaseAt } from "./upcaseAt.js";
import assertUnreachable from "./assertUnreachable.js";
import only from "./only.js";
import maybeMap from "./maybeMap.js";
import applyMixins from "./applyMixins.js";

@@ -38,30 +39,21 @@ export type Concat<T, S, V> = string;

// If the tuple provided has at least one required value
TUPLE extends [infer NEXT_PARAM, ...infer REMAINING]
? // recurse back in to this type with one less item
// in the original tuple, and the latest extracted value
// added to the extracted list as optional
PartialTuple<REMAINING, [...EXTRACTED, NEXT_PARAM?]>
: // else if there are no more values,
// return an empty tuple so that too is a valid option
[...EXTRACTED, ...TUPLE];
type PartialParameters<FN extends (...args: any[]) => any> = PartialTuple<Parameters<FN>>;
TUPLE extends [infer NEXT_PARAM, ...(infer REMAINING)] // recurse back in to this type with one less item // in the original tuple, and the latest extracted value // added to the extracted list as optional
? PartialTuple<REMAINING, [...EXTRACTED, NEXT_PARAM?]> // else if there are no more values, // return an empty tuple so that too is a valid option
: [...EXTRACTED, ...TUPLE];
type PartialParameters<FN extends (...args: any[]) => any> = PartialTuple<
Parameters<FN>
>;
type RemainingParameters<PROVIDED extends any[], EXPECTED extends any[]> =
// if the expected array has any required items…
EXPECTED extends [infer E1, ...infer EX]
? // if the provided array has at least one required item
PROVIDED extends [infer P1, ...infer PX]
? // if the type is correct, recurse with one item less
//in each array type
P1 extends E1
? RemainingParameters<PX, EX>
: // else return this as invalid
never
: // else the remaining args is unchanged
EXPECTED
: // else there are no more arguments
[];
EXPECTED extends [infer E1, ...(infer EX)] // if the provided array has at least one required item
? PROVIDED extends [infer P1, ...(infer PX)] // if the type is correct, recurse with one item less //in each array type
? P1 extends E1
? RemainingParameters<PX, EX> // else return this as invalid
: never // else the remaining args is unchanged
: EXPECTED // else there are no more arguments
: [];
type CurriedFunctionOrReturnValue<
PROVIDED extends any[],
FN extends (...args: any[]) => any,
FN extends (...args: any[]) => any
> = RemainingParameters<PROVIDED, Parameters<FN>> extends [any, ...any[]]

@@ -71,4 +63,7 @@ ? CurriedFunction<PROVIDED, FN>

type CurriedFunction<PROVIDED extends any[], FN extends (...args: any[]) => any> = <
NEW_ARGS extends PartialTuple<RemainingParameters<PROVIDED, Parameters<FN>>>,
type CurriedFunction<
PROVIDED extends any[],
FN extends (...args: any[]) => any
> = <
NEW_ARGS extends PartialTuple<RemainingParameters<PROVIDED, Parameters<FN>>>
>(

@@ -78,7 +73,10 @@ ...args: NEW_ARGS

function curry<FN extends (...args: any[]) => any, STARTING_ARGS extends PartialParameters<FN>>(
function curry<
FN extends (...args: any[]) => any,
STARTING_ARGS extends PartialParameters<FN>
>(
targetFn: FN,
...existingArgs: STARTING_ARGS
): CurriedFunction<STARTING_ARGS, FN> {
return function (...args) {
return function(...args) {
const totalArgs = [...existingArgs, ...args];

@@ -121,2 +119,3 @@ if (totalArgs.length >= targetFn.length) {

isHex,
applyMixins,
};