cmath-js 1.0.5 → 1.0.7

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/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "cmath-js",
3
- "homepage": "https://github.com/oskarlh/cmath.js",
4
- "repository": "github:oskarlh/cmath.js",
5
- "version": "1.0.5",
3
+ "homepage": "https://github.com/oskarlh/cmath-js",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/oskarlh/cmath-js.git"
7
+ },
8
+ "version": "1.0.7",
6
9
  "main": "dist/index.js",
7
10
  "types": "dist/index.d.ts",
8
11
  "type": "module",
@@ -10,45 +13,45 @@
10
13
  "license": "MIT",
11
14
  "description": "C's math functions implemented in TypeScript/JavaScript",
12
15
  "keywords": [
13
- "cmath",
16
+ "Browser",
14
17
  "C",
15
18
  "C++",
19
+ "cmath",
20
+ "ECMAScript",
21
+ "JavaScript",
16
22
  "Math",
17
23
  "Maths",
18
- "JavaScript",
19
- "ECMAScript",
20
- "TypeScript",
21
24
  "Node",
22
25
  "NodeJS",
23
- "Web",
24
- "Browser"
26
+ "TypeScript",
27
+ "Web"
25
28
  ],
26
29
  "devDependencies": {
27
- "@swc/cli": "^0.1.57",
28
- "@swc/core": "^1.3.18",
29
- "@swc/jest": "^0.2.23",
30
+ "@swc/cli": "^0.1",
31
+ "@swc/core": "^1",
32
+ "@swc/jest": "^0.2",
30
33
  "@types/jest": "^29",
31
34
  "@types/node": "^20",
32
- "@typescript-eslint/eslint-plugin": "^6.2",
33
- "@typescript-eslint/parser": "^6.2",
34
- "eslint": "^8.5.0",
35
- "eslint-config-prettier": "^8.3.0",
35
+ "@typescript-eslint/eslint-plugin": "^6",
36
+ "@typescript-eslint/parser": "^6",
37
+ "eslint": "^8",
38
+ "eslint-config-prettier": "^9",
36
39
  "eslint-plugin-prettier": "^5",
37
- "jest": "^29.3.1",
40
+ "jest": "^29",
38
41
  "prettier": "^3",
39
- "ts-jest": "^29.0.3",
40
- "typescript": "~5.1"
42
+ "ts-jest": "^29",
43
+ "typescript": "~5.2"
41
44
  },
42
45
  "scripts": {
43
46
  "build": "tsc",
44
47
  "build-and-verify": "npm run test-with-typechecking --ci && npm run lint && npm run build",
45
48
  "build-without-typechecking": "swc -C exclude=.test.ts -d dist -s true -- src",
46
49
  "lint": "eslint .",
50
+ "prepack": "npm run build",
47
51
  "test": "jest",
48
52
  "test-with-typechecking": "jest --config=jest.config.with-typechecking.js"
49
53
  },
50
54
  "files": [
51
- "dist",
52
- "README.md"
55
+ "dist"
53
56
  ]
54
57
  }
@@ -1 +0,0 @@
1
- export declare function copysign(num: number, sign: number): number;
@@ -1,4 +0,0 @@
1
- export function copysign(num, sign) {
2
- return Math.abs(num) * (Object.is(0 * Math.sign(sign), -0) ? -1 : 1);
3
- }
4
- //# sourceMappingURL=copysign.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"copysign.js","sourceRoot":"","sources":["../../src/double/copysign.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,QAAQ,CAAY,GAAW,EAAa,IAAY;IACvE,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACtE,CAAC"}
@@ -1 +0,0 @@
1
- export declare const fabs: (x: number) => number;
@@ -1,2 +0,0 @@
1
- export const fabs = Math.abs;
2
- //# sourceMappingURL=fabs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fabs.js","sourceRoot":"","sources":["../../src/double/fabs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC"}
@@ -1 +0,0 @@
1
- export declare function frexp(num: number): [fraction: number, exponent: number];
@@ -1,23 +0,0 @@
1
- export function frexp(num) {
2
- const result = [num, 0];
3
- if (num !== 0 && Number.isFinite(num)) {
4
- const absNum = Math.abs(num);
5
- let exp = Math.max(-1023, Math.floor(Math.log2(absNum)) + 1);
6
- let x = absNum * 2 ** -exp;
7
- while (x < 0.5) {
8
- x *= 2;
9
- --exp;
10
- }
11
- while (x >= 1) {
12
- x *= 0.5;
13
- ++exp;
14
- }
15
- if (num < 0) {
16
- x = -x;
17
- }
18
- result[0] = x;
19
- result[1] = exp;
20
- }
21
- return result;
22
- }
23
- //# sourceMappingURL=frexp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"frexp.js","sourceRoot":"","sources":["../../src/double/frexp.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,KAAK,CACT,GAAW;IAEtB,MAAM,MAAM,GAAqB,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAE1C,IAAI,GAAG,KAAK,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACtC,MAAM,MAAM,GAAW,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAErC,IAAI,GAAG,GAAW,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,GAAW,MAAM,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;QAInC,OAAO,CAAC,GAAG,GAAG,EAAE;YACf,CAAC,IAAI,CAAC,CAAC;YACP,EAAE,GAAG,CAAC;SACN;QAGD,OAAO,CAAC,IAAI,CAAC,EAAE;YACd,CAAC,IAAI,GAAG,CAAC;YACT,EAAE,GAAG,CAAC;SACN;QAED,IAAI,GAAG,GAAG,CAAC,EAAE;YACZ,CAAC,GAAG,CAAC,CAAC,CAAC;SACP;QACD,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACd,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;KAChB;IACD,OAAO,MAAM,CAAC;AACf,CAAC"}
@@ -1 +0,0 @@
1
- export declare function hypot(x: number, y: number, z?: number): number;
@@ -1,19 +0,0 @@
1
- export function hypot(x, y, z) {
2
- let result = 0;
3
- if (z !== undefined) {
4
- result = Math.hypot(x, y, z);
5
- }
6
- else {
7
- result = Infinity;
8
- if (x !== Infinity && x !== -Infinity && y !== Infinity && y !== -Infinity) {
9
- if (x === 0 || y === 0) {
10
- result = Math.max(Math.abs(x), Math.abs(y));
11
- }
12
- else {
13
- result = Math.hypot(x, y);
14
- }
15
- }
16
- }
17
- return result;
18
- }
19
- //# sourceMappingURL=hypot.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hypot.js","sourceRoot":"","sources":["../../src/double/hypot.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,KAAK,CAAY,CAAS,EAAa,CAAS,EAAa,CAAU;IACtF,IAAI,MAAM,GAAW,CAAC,CAAC;IACvB,IAAI,CAAC,KAAK,SAAS,EAAE;QACpB,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;KAC7B;SAAM;QACN,MAAM,GAAG,QAAQ,CAAC;QAClB,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YAC3E,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;gBACvB,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;aAC5C;iBAAM;gBACN,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;aAC1B;SACD;KACD;IACD,OAAO,MAAM,CAAC;AACf,CAAC"}
@@ -1,8 +0,0 @@
1
- export { copysign } from "./copysign.js";
2
- export { fabs } from "./fabs.js";
3
- export { frexp } from "./frexp.js";
4
- export { hypot } from "./hypot.js";
5
- export { ldexp } from "./ldexp.js";
6
- export { nextafter } from "./nextafter.js";
7
- export { pow } from "./pow.js";
8
- export { signbit } from "./signbit.js";
@@ -1,9 +0,0 @@
1
- export { copysign } from "./copysign.js";
2
- export { fabs } from "./fabs.js";
3
- export { frexp } from "./frexp.js";
4
- export { hypot } from "./hypot.js";
5
- export { ldexp } from "./ldexp.js";
6
- export { nextafter } from "./nextafter.js";
7
- export { pow } from "./pow.js";
8
- export { signbit } from "./signbit.js";
9
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/double/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
@@ -1 +0,0 @@
1
- export declare function ldexp(factor: number, exponent: number): number;
@@ -1,5 +0,0 @@
1
- export function ldexp(factor, exponent) {
2
- const halfPowerRoundedTowardZero = 2 ** Math.trunc(exponent * 0.5);
3
- return (factor * halfPowerRoundedTowardZero * halfPowerRoundedTowardZero * 2 ** Math.sign(exponent % 2));
4
- }
5
- //# sourceMappingURL=ldexp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ldexp.js","sourceRoot":"","sources":["../../src/double/ldexp.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,KAAK,CAAY,MAAc,EAAU,QAAgB;IACxE,MAAM,0BAA0B,GAAW,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC;IAC3E,OAAO,CACN,MAAM,GAAG,0BAA0B,GAAG,0BAA0B,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAC/F,CAAC;AACH,CAAC"}
@@ -1 +0,0 @@
1
- export declare function nextafter(num: number, toward: number): number;
@@ -1,22 +0,0 @@
1
- export function nextafter(num, toward) {
2
- if (num === toward) {
3
- return toward;
4
- }
5
- if (num === 0) {
6
- return Math.sign(toward) * Number.MIN_VALUE;
7
- }
8
- if (num === Infinity || num === -Infinity) {
9
- return Number.MAX_VALUE * Math.sign(num);
10
- }
11
- if (num === -Number.MIN_VALUE && toward > num) {
12
- return -0;
13
- }
14
- let differenceMultiplier = 0.5 * Math.sign(num) * (num < toward ? 1 : -1);
15
- let result;
16
- do {
17
- result = num + num * (Number.EPSILON * differenceMultiplier);
18
- differenceMultiplier *= 2;
19
- } while (result === num);
20
- return result;
21
- }
22
- //# sourceMappingURL=nextafter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nextafter.js","sourceRoot":"","sources":["../../src/double/nextafter.ts"],"names":[],"mappings":"AACA,MAAM,UAAU,SAAS,CAAY,GAAW,EAAa,MAAc;IAC1E,IAAI,GAAG,KAAK,MAAM,EAAE;QACnB,OAAO,MAAM,CAAC;KACd;IACD,IAAI,GAAG,KAAK,CAAC,EAAE;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC;KAC5C;IACD,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,CAAC,QAAQ,EAAE;QAC1C,OAAO,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACzC;IACD,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,IAAI,MAAM,GAAG,GAAG,EAAE;QAC9C,OAAO,CAAC,CAAC,CAAC;KACV;IACD,IAAI,oBAAoB,GAAG,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,IAAI,MAAc,CAAC;IACnB,GAAG;QACF,MAAM,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,OAAO,GAAG,oBAAoB,CAAC,CAAC;QAC7D,oBAAoB,IAAI,CAAC,CAAC;KAC1B,QAAQ,MAAM,KAAK,GAAG,EAAE;IACzB,OAAO,MAAM,CAAC;AACf,CAAC"}
@@ -1 +0,0 @@
1
- export declare function pow(base: number, exponent: number): number;
@@ -1,8 +0,0 @@
1
- export function pow(base, exponent) {
2
- let result = base ** exponent;
3
- if (base === 1 || (base === -1 && (exponent === Infinity || exponent === -Infinity))) {
4
- result = 1;
5
- }
6
- return result;
7
- }
8
- //# sourceMappingURL=pow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pow.js","sourceRoot":"","sources":["../../src/double/pow.ts"],"names":[],"mappings":"AACA,MAAM,UAAU,GAAG,CAAY,IAAY,EAAa,QAAgB;IACvE,IAAI,MAAM,GAAG,IAAI,IAAI,QAAQ,CAAC;IAC9B,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE;QACrF,MAAM,GAAG,CAAC,CAAC;KACX;IACD,OAAO,MAAM,CAAC;AACf,CAAC"}
@@ -1 +0,0 @@
1
- export declare function signbit(num: number): boolean;
@@ -1,4 +0,0 @@
1
- export function signbit(num) {
2
- return Object.is(num, -0) || num < 0;
3
- }
4
- //# sourceMappingURL=signbit.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signbit.js","sourceRoot":"","sources":["../../src/double/signbit.ts"],"names":[],"mappings":"AACA,MAAM,UAAU,OAAO,CAAY,GAAW;IAC7C,OAAO,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;AACtC,CAAC"}
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from "./double/index.js";
2
- export * from "./integer/index.js";
package/dist/index.js DELETED
@@ -1,3 +0,0 @@
1
- export * from "./double/index.js";
2
- export * from "./integer/index.js";
3
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
@@ -1 +0,0 @@
1
- export declare function abs(number: bigint | number): number | bigint;
@@ -1,7 +0,0 @@
1
- export function abs(number) {
2
- if (number < 0 || Object.is(number, -0)) {
3
- return -number;
4
- }
5
- return number;
6
- }
7
- //# sourceMappingURL=abs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"abs.js","sourceRoot":"","sources":["../../src/integer/abs.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAG,CAAC,MAAuB;IAC1C,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE;QACxC,OAAO,CAAC,MAAM,CAAC;KACf;IACD,OAAO,MAAM,CAAC;AACf,CAAC"}
@@ -1 +0,0 @@
1
- export { abs } from "./abs.js";
@@ -1,2 +0,0 @@
1
- export { abs } from "./abs.js";
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/integer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC"}