extra-utils 5.10.0 → 5.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,8 +20,8 @@ function last<T>(arr: ArrayLike<T>): T | undefined
20
20
  function isArray<T>(val: unknown): val is Array<T>
21
21
  function isntArray<T>(val: T): val is Exclude<T, Array<unknown>>
22
22
 
23
- function isEmptyArray(val: unknown[]): boolean
24
- function isntEmptyArray<T>(val: T[]): val is NonEmptyArray<T>
23
+ function isEmptyArray(val: readonly unknown[]): boolean
24
+ function isntEmptyArray<T>(val: readonly T[]): val is NonEmptyArray<T>
25
25
  ```
26
26
 
27
27
  ### Boolean
@@ -83,6 +83,11 @@ function remap(
83
83
  , [oldMin, oldMax]: readonly [oldMin: number, oldMax: number]
84
84
  , [newMin, newMax]: readonly [newMin: number, newMax: number]
85
85
  ): number
86
+
87
+ function lerp(
88
+ alpha: number
89
+ , [from, to]: readonly [from: number, to: number]
90
+ ): number
86
91
  ```
87
92
 
88
93
  ### Object
@@ -1,3 +1,3 @@
1
1
  import { NonEmptyArray } from 'justypes';
2
- export declare function isEmptyArray(val: unknown[]): boolean;
3
- export declare function isntEmptyArray<T>(val: T[]): val is NonEmptyArray<T>;
2
+ export declare function isEmptyArray(val: readonly unknown[]): boolean;
3
+ export declare function isntEmptyArray<T>(val: readonly T[]): val is NonEmptyArray<T>;
@@ -1 +1 @@
1
- {"version":3,"file":"is-empty-array.js","sourceRoot":"","sources":["../../src/array/is-empty-array.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,YAAY,CAAC,GAAc;IACzC,OAAO,GAAG,CAAC,MAAM,KAAK,CAAC,CAAA;AACzB,CAAC;AAED,MAAM,UAAU,cAAc,CAAI,GAAQ;IACxC,OAAO,GAAG,CAAC,MAAM,KAAK,CAAC,CAAA;AACzB,CAAC"}
1
+ {"version":3,"file":"is-empty-array.js","sourceRoot":"","sources":["../../src/array/is-empty-array.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,YAAY,CAAC,GAAuB;IAClD,OAAO,GAAG,CAAC,MAAM,KAAK,CAAC,CAAA;AACzB,CAAC;AAED,MAAM,UAAU,cAAc,CAAI,GAAiB;IACjD,OAAO,GAAG,CAAC,MAAM,KAAK,CAAC,CAAA;AACzB,CAAC"}
@@ -5,3 +5,4 @@ export * from './is-nan.js';
5
5
  export * from './is-number.js';
6
6
  export * from './clamp.js';
7
7
  export * from './remap.js';
8
+ export * from './lerp.js';
@@ -5,4 +5,5 @@ export * from './is-nan.js';
5
5
  export * from './is-number.js';
6
6
  export * from './clamp.js';
7
7
  export * from './remap.js';
8
+ export * from './lerp.js';
8
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/number/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/number/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
@@ -0,0 +1 @@
1
+ export declare function lerp(alpha: number, [from, to]: readonly [from: number, to: number]): number;
@@ -0,0 +1,4 @@
1
+ export function lerp(alpha, [from, to]) {
2
+ return from + (to - from) * alpha;
3
+ }
4
+ //# sourceMappingURL=lerp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lerp.js","sourceRoot":"","sources":["../../src/number/lerp.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,IAAI,CAClB,KAAa,EACb,CAAC,IAAI,EAAE,EAAE,CAAsC;IAE/C,OAAO,IAAI,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,KAAK,CAAA;AACnC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extra-utils",
3
- "version": "5.10.0",
3
+ "version": "5.12.0",
4
4
  "description": "Utilities for JavaScript and Typescript",
5
5
  "files": [
6
6
  "src",
@@ -1,9 +1,9 @@
1
1
  import { NonEmptyArray } from 'justypes'
2
2
 
3
- export function isEmptyArray(val: unknown[]): boolean {
3
+ export function isEmptyArray(val: readonly unknown[]): boolean {
4
4
  return val.length === 0
5
5
  }
6
6
 
7
- export function isntEmptyArray<T>(val: T[]): val is NonEmptyArray<T> {
7
+ export function isntEmptyArray<T>(val: readonly T[]): val is NonEmptyArray<T> {
8
8
  return val.length !== 0
9
9
  }
@@ -5,3 +5,4 @@ export * from './is-nan.js'
5
5
  export * from './is-number.js'
6
6
  export * from './clamp.js'
7
7
  export * from './remap.js'
8
+ export * from './lerp.js'
@@ -0,0 +1,6 @@
1
+ export function lerp(
2
+ alpha: number
3
+ , [from, to]: readonly [from: number, to: number]
4
+ ): number {
5
+ return from + (to - from) * alpha
6
+ }