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

bind-deep

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bind-deep - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

types-versions/ts4.1/index.d.ts

70

index.d.ts

@@ -15,28 +15,25 @@ /**

export declare type BoundDeepProperties<
ToBind,
BoundArguments extends Array<unknown>
// `object` is being used as the reverse of `Primitive` only for the conditional type, so this is a desired use case
// eslint-disable-next-line @typescript-eslint/ban-types
> = ToBind extends object ? {
[key in keyof ToBind]: BoundDeepFunction<ToBind[key], BoundArguments>;
} : ToBind;
ToBind,
BoundArguments extends ReadonlyArray<unknown>,
// `object` is being used as the reverse of `Primitive` only for the conditional type, so this is a desired use case
// eslint-disable-next-line @typescript-eslint/ban-types
> = ToBind extends object ? {
[key in keyof ToBind]: BoundDeepFunction<ToBind[key], BoundArguments>;
} : ToBind;
/*
Return a bound function
- These `ts-toolbelt` utils use iteration magic, so if issues arise from long argument lists, type the
function manually
- Removes `this` while also removing the arguments provided to `bindDeep`
- Existing arguments and return value are inferred, so if you will have to manually retype the function if you also
expect these values to be different after binding. `ReturnType<T>` and other TS util types are your friends!
- `this` is removed to allow the bound function to be called (counterintuitive, I know)
*/
export declare type BoundDeepFunction<
ToBind,
BoundArguments extends Array<unknown>
> = ToBind extends (...args: infer OriginalArguments) => infer ReturnValue ? (
/*
Remove `this` while also removing the arguments provided to `bindDeep`
- These `ts-toolbelt` utils use iteration magic, so if issues arise from long argument lists, type the
function manually
- Existing arguments and return value are inferred (similar to `OmitThisParameter<T>`), so if you will have
to manually retype the function if you also expect these values to be different after binding
- `ReturnType<T>` and other TS util types are your friends!
- `this` is removed to allow the bound function to be called (counterintuitive, I know); however you can
add a type parameter for `this` and make the following line `((this: ThisType, ...args [...]` if you'd
like to repurpose this type
*/
ToBind,
BoundArguments extends ReadonlyArray<unknown>,
> = (
// Is callable function? Infer arguments and return values
ToBind extends (...args: infer OriginalArguments) => infer ReturnValue ? (
((...args:

@@ -55,5 +52,20 @@ // Leave original arguments if none are being bound

) => ReturnValue)
&
BoundDeepProperties<ToBind, BoundArguments> // Bind properties of the function
) : BoundDeepProperties<ToBind, BoundArguments>; // Bind properties of the object or return the primitive
) :
// Is newable function? Infer arguments and return values
ToBind extends new (...args: infer OriginalArguments) => infer ReturnValue ? (
(new (...args:
// Leave original arguments if none are being bound
BoundArguments["length"] extends 0 ? OriginalArguments
// Remove the arguments that were bound otherwise
: List.Remove<
OriginalArguments,
"0",
Number.Minus<
Number.NumberOf<BoundArguments["length"]>,
"1"
>
>
) => ReturnValue)
) : unknown // Not a function
) & BoundDeepProperties<ToBind, BoundArguments>; // Bind properties of the object or return the primitive

@@ -83,6 +95,6 @@ /*

export default function bindDeep<
ToBind,
BoundArguments extends Array<unknown>
>
(object: ToBind, thisArg: unknown, ...args: BoundArguments)
: BoundDeepFunction<ToBind, BoundArguments>;
ToBind,
BoundArguments extends ReadonlyArray<unknown>,
> (
object: ToBind, thisArg: ThisParameterType<ToBind>, ...args: BoundArguments,
) : BoundDeepFunction<ToBind, BoundArguments>;
{
"name": "bind-deep",
"version": "2.1.0",
"version": "2.2.0",
"description": "Lightweight module for binding a function or object deeply.",

@@ -24,2 +24,9 @@ "keywords": [

"types": "./index.d.ts",
"typesVersions": {
">=4.1": {
"*": [
"./types-versions/ts4.1/*"
]
}
},
"directories": {

@@ -31,2 +38,3 @@ "lib": "./lib",

"/lib",
"/types-versions",
"/index.d.ts"

@@ -41,20 +49,21 @@ ],

"dependencies": {
"ts-toolbelt": "^6.9.4"
"ts-toolbelt": "^8.0.7"
},
"devDependencies": {
"@babel/cli": "^7.10.1",
"@babel/core": "^7.10.2",
"@babel/preset-env": "^7.10.2",
"@typescript-eslint/eslint-plugin": "^3.1.0",
"@typescript-eslint/parser": "^3.1.0",
"@babel/cli": "^7.12.8",
"@babel/core": "^7.12.9",
"@babel/preset-env": "^7.12.7",
"@typescript-eslint/eslint-plugin": "^4.8.2",
"@typescript-eslint/parser": "^4.8.2",
"babel-eslint": "^10.1.0",
"chai": "^4.2.0",
"eslint": "^7.2.0",
"eslint-plugin-evelyn": "^3.0.0-alpha.3",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-mocha": "^7.0.1",
"eslint": "^7.14.0",
"eslint-plugin-evelyn": "^4.0.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-mocha": "^8.0.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-unicorn": "^20.1.0",
"mocha": "^7.2.0",
"typescript": "^3.9.5"
"eslint-plugin-regexp": "^0.1.1",
"eslint-plugin-unicorn": "^23.0.0",
"mocha": "^8.2.1",
"typescript": "^4.1.2"
},

@@ -61,0 +70,0 @@ "engines": {

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