extra-utils 5.8.0 → 5.10.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
@@ -75,7 +75,13 @@ function isntBigInt<T>(val: T): val is Exclude<T, bigint>
75
75
 
76
76
  function clamp(
77
77
  val: number
78
- , [min, max]: [min: number, max: number]
78
+ , [min, max]: readonly [min: number, max: number]
79
+ ): number
80
+
81
+ function remap(
82
+ value: number
83
+ , [oldMin, oldMax]: readonly [oldMin: number, oldMax: number]
84
+ , [newMin, newMax]: readonly [newMin: number, newMax: number]
79
85
  ): number
80
86
  ```
81
87
 
@@ -252,6 +258,7 @@ function isntSymbol<T>(val: T): val is Exclude<T, symbol>
252
258
  function max(result: number, current: number): number
253
259
  function min(result: number, current: number): number
254
260
  function sum(result: number, current: number): number
261
+ function product(result: number, current: number): number
255
262
  ```
256
263
 
257
264
  ### pipe
@@ -1 +1 @@
1
- export declare function clamp(val: number, [min, max]: [min: number, max: number]): number;
1
+ export declare function clamp(val: number, [min, max]: readonly [min: number, max: number]): number;
@@ -1 +1 @@
1
- {"version":3,"file":"clamp.js","sourceRoot":"","sources":["../../src/number/clamp.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,KAAK,CACnB,GAAW,EACX,CAAC,GAAG,EAAE,GAAG,CAA6B;IAEtC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;AAC1C,CAAC"}
1
+ {"version":3,"file":"clamp.js","sourceRoot":"","sources":["../../src/number/clamp.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,KAAK,CACnB,GAAW,EACX,CAAC,GAAG,EAAE,GAAG,CAAsC;IAE/C,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;AAC1C,CAAC"}
@@ -4,3 +4,4 @@ export * from './is-infinity.js';
4
4
  export * from './is-nan.js';
5
5
  export * from './is-number.js';
6
6
  export * from './clamp.js';
7
+ export * from './remap.js';
@@ -4,4 +4,5 @@ export * from './is-infinity.js';
4
4
  export * from './is-nan.js';
5
5
  export * from './is-number.js';
6
6
  export * from './clamp.js';
7
+ export * from './remap.js';
7
8
  //# 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"}
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"}
@@ -0,0 +1 @@
1
+ export declare function remap(value: number, [oldMin, oldMax]: readonly [oldMin: number, oldMax: number], [newMin, newMax]: readonly [newMin: number, newMax: number]): number;
@@ -0,0 +1,6 @@
1
+ export function remap(value, [oldMin, oldMax], [newMin, newMax]) {
2
+ return (value - oldMin) / (oldMax - oldMin)
3
+ * (newMax - newMin)
4
+ + newMin;
5
+ }
6
+ //# sourceMappingURL=remap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remap.js","sourceRoot":"","sources":["../../src/number/remap.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,KAAK,CACnB,KAAa,EACb,CAAC,MAAM,EAAE,MAAM,CAA4C,EAC3D,CAAC,MAAM,EAAE,MAAM,CAA4C;IAE3D,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;UACpC,CAAC,MAAM,GAAG,MAAM,CAAC;UACjB,MAAM,CAAA;AACf,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from './max.js';
2
2
  export * from './min.js';
3
3
  export * from './sum.js';
4
+ export * from './product.js';
@@ -1,4 +1,5 @@
1
1
  export * from './max.js';
2
2
  export * from './min.js';
3
3
  export * from './sum.js';
4
+ export * from './product.js';
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reducers/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reducers/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA"}
@@ -0,0 +1 @@
1
+ export declare function product(result: number, current: number): number;
@@ -0,0 +1,4 @@
1
+ export function product(result, current) {
2
+ return result * current;
3
+ }
4
+ //# sourceMappingURL=product.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product.js","sourceRoot":"","sources":["../../src/reducers/product.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO,CAAC,MAAc,EAAE,OAAe;IACrD,OAAO,MAAM,GAAG,OAAO,CAAA;AACzB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extra-utils",
3
- "version": "5.8.0",
3
+ "version": "5.10.0",
4
4
  "description": "Utilities for JavaScript and Typescript",
5
5
  "files": [
6
6
  "src",
@@ -1,6 +1,6 @@
1
1
  export function clamp(
2
2
  val: number
3
- , [min, max]: [min: number, max: number]
3
+ , [min, max]: readonly [min: number, max: number]
4
4
  ): number {
5
5
  return Math.max(min, Math.min(val, max))
6
6
  }
@@ -4,3 +4,4 @@ export * from './is-infinity.js'
4
4
  export * from './is-nan.js'
5
5
  export * from './is-number.js'
6
6
  export * from './clamp.js'
7
+ export * from './remap.js'
@@ -0,0 +1,9 @@
1
+ export function remap(
2
+ value: number
3
+ , [oldMin, oldMax]: readonly [oldMin: number, oldMax: number]
4
+ , [newMin, newMax]: readonly [newMin: number, newMax: number]
5
+ ): number {
6
+ return (value - oldMin) / (oldMax - oldMin)
7
+ * (newMax - newMin)
8
+ + newMin
9
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './max.js'
2
2
  export * from './min.js'
3
3
  export * from './sum.js'
4
+ export * from './product.js'
@@ -0,0 +1,3 @@
1
+ export function product(result: number, current: number): number {
2
+ return result * current
3
+ }