@mathigon/core
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -25,3 +25,3 @@ module.exports = { | ||
'guard-for-in': 'error', | ||
'indent': ['error', 2], | ||
'indent': ['error', 2, {SwitchCase: 1}], | ||
'key-spacing': 'error', | ||
@@ -72,2 +72,3 @@ 'keyword-spacing': 'error', | ||
'switch-colon-spacing': 'error', | ||
'template-curly-spacing': ['error', 'never'], | ||
'yield-star-spacing': ['error', 'after'], | ||
@@ -74,0 +75,0 @@ '@typescript-eslint/no-unused-vars': ['warn', {'varsIgnorePattern': '^_', 'argsIgnorePattern': '^_'}], |
@@ -32,3 +32,3 @@ /** Object Map Interface. */ | ||
*/ | ||
export declare function cache<T>(fn: (...args: unknown[]) => T): (...args: unknown[]) => NonNullable<T>; | ||
export declare function cache<T, Args extends unknown[]>(fn: (...args: Args) => T): (...args: Args) => NonNullable<T>; | ||
/** | ||
@@ -41,4 +41,4 @@ * Function wrapper that prevents a function from being executed more than once | ||
*/ | ||
export declare function throttle(fn: (...args: unknown[]) => void, t?: number, forceDelay?: boolean): (...args: unknown[]) => void; | ||
export declare function throttle<Args extends unknown[]>(fn: (...args: Args) => void, t?: number, forceDelay?: boolean): (...args: Args) => void; | ||
/** Safe wrapper for JSON.parse. */ | ||
export declare function safeToJSON(str?: string, fallback?: unknown): unknown; |
{ | ||
"name": "@mathigon/core", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "homepage": "https://mathigon.io/core", |
@@ -52,3 +52,3 @@ // ============================================================================= | ||
const alpha = this.a >= 1 ? '' : pad2(Math.round(this.a * 255).toString(16)); | ||
return `#${ c.join('') }${alpha}`; | ||
return `#${c.join('')}${alpha}`; | ||
} | ||
@@ -59,3 +59,3 @@ | ||
const c = [this.r, this.g, this.b].map(x => Math.round(x)).join(','); | ||
return `rgba(${ c },${ this.a })`; | ||
return `rgba(${c},${this.a})`; | ||
} | ||
@@ -62,0 +62,0 @@ |
@@ -103,5 +103,5 @@ // ============================================================================= | ||
*/ | ||
export function cache<T>(fn: (...args: unknown[]) => T) { | ||
export function cache<T, Args extends unknown[]>(fn: (...args: Args) => T) { | ||
const cached = new Map<string, T|CacheError>(); | ||
return function(...args: unknown[]) { | ||
return function(...args: Args) { | ||
const argString = args.join('--'); | ||
@@ -129,7 +129,7 @@ if (!cached.has(argString)) { | ||
*/ | ||
export function throttle(fn: (...args: unknown[]) => void, t = 0, forceDelay = false) { | ||
export function throttle<Args extends unknown[]>(fn: (...args: Args) => void, t = 0, forceDelay = false) { | ||
let delay = false; | ||
let repeat = false; | ||
return (...args: unknown[]) => { | ||
return (...args: Args) => { | ||
if (delay) { | ||
@@ -136,0 +136,0 @@ repeat = true; |
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
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
160477
2529
0