@opencreek/ext
Advanced tools
Comparing version 1.0.2 to 1.1.0--canary.1.c7fdd1ae303a59b3ef529a08735b2d44b9564296.0
@@ -1,2 +0,11 @@ | ||
export default function extendProtoype(target: Function, func: Function, functionName: string): void; | ||
export declare function extendProtoype(target: Function, func: Function, functionName: string): 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 [ | ||
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>>; | ||
export declare function apply<F extends (...args: any) => any>(f: F): ThisFunction<F>; | ||
export {}; | ||
//# sourceMappingURL=extendPrototype.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.apply = exports.extendProtoype = void 0; | ||
/* eslint-disable @typescript-eslint/ban-types */ | ||
@@ -12,3 +13,9 @@ function extendProtoype(target, func, functionName) { | ||
} | ||
exports.default = extendProtoype; | ||
exports.extendProtoype = extendProtoype; | ||
function apply(f) { | ||
return function (...b) { | ||
return f(this, ...b); | ||
}; | ||
} | ||
exports.apply = apply; | ||
//# sourceMappingURL=extendPrototype.js.map |
@@ -5,2 +5,4 @@ export * from "./error"; | ||
export * from "./raise"; | ||
export * from "./collections"; | ||
export * from "./objects"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -17,2 +17,4 @@ "use strict"; | ||
__exportStar(require("./raise"), exports); | ||
__exportStar(require("./collections"), exports); | ||
__exportStar(require("./objects"), exports); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@opencreek/ext", | ||
"version": "1.0.2", | ||
"version": "1.1.0--canary.1.c7fdd1ae303a59b3ef529a08735b2d44b9564296.0", | ||
"description": "", | ||
@@ -37,3 +37,6 @@ "main": "build/index.js", | ||
"semi": false | ||
}, | ||
"dependencies": { | ||
"@opencreek/deno-std-collections": "^0.109.0" | ||
} | ||
} |
@@ -1,1 +0,1 @@ | ||
# typescript-extensions | ||
# typescript-extensions |
@@ -5,6 +5,4 @@ /** | ||
*/ | ||
export function error( | ||
msg?: string | ||
): never { | ||
throw new Error(msg) | ||
export function error(msg?: string): never { | ||
throw new Error(msg) | ||
} |
/* eslint-disable @typescript-eslint/ban-types */ | ||
export default function extendProtoype( | ||
target: Function, | ||
func: Function, | ||
functionName: string | ||
export function extendProtoype( | ||
target: Function, | ||
func: Function, | ||
functionName: string | ||
): void { | ||
if (!Object.getOwnPropertyNames(target.prototype).includes(functionName)) { | ||
Object.defineProperty(target.prototype, functionName, { | ||
value: func, | ||
writable: true, | ||
}) | ||
} | ||
if (!Object.getOwnPropertyNames(target.prototype).includes(functionName)) { | ||
Object.defineProperty(target.prototype, functionName, { | ||
value: func, | ||
writable: true, | ||
}) | ||
} | ||
} | ||
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 | ||
type SkipFirst<T extends unknown[]> = T extends [infer _, ...infer R] | ||
? [...R] | ||
: never | ||
type SkipFirstParameter<F extends (...args: any) => any> = SkipFirst< | ||
Parameters<F> | ||
> | ||
export function apply<F extends (...args: any) => any>(f: F): ThisFunction<F> { | ||
return function (this: FirstParameter<F>, ...b: SkipFirstParameter<F>) { | ||
return f(this, ...b) | ||
} | ||
} |
@@ -5,1 +5,3 @@ export * from "./error" | ||
export * from "./raise" | ||
export * from "./collections" | ||
export * from "./objects" |
export function undefinedIfNaN(n: number): number | undefined { | ||
if (isNaN(n)) { | ||
return undefined | ||
} | ||
if (isNaN(n)) { | ||
return undefined | ||
} | ||
return n | ||
return n | ||
} | ||
export function parseIntOrUndefined( | ||
s: string, | ||
radix?: number | ||
s: string, | ||
radix?: number | ||
): number | undefined { | ||
return undefinedIfNaN(parseInt(s, radix)) | ||
return undefinedIfNaN(parseInt(s, radix)) | ||
} | ||
export function parseFloatOrUndefined(s: string): number | undefined { | ||
return undefinedIfNaN(parseFloat(s)) | ||
return undefinedIfNaN(parseFloat(s)) | ||
} |
@@ -11,3 +11,3 @@ /** | ||
export function raise(error: Error): never { | ||
throw error | ||
throw error | ||
} |
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33056
39
517
2
1
2
1
+ Added@opencreek/deno-std-collections@0.109.1(transitive)