@zukhruf/python 0.8.272 → 0.8.274

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
@@ -42,6 +42,7 @@ new RegExp(`[${PYTHON_WORD}]+`, 'u'); // Python's \w
42
42
  | `NeumaierSum` | `sum()` of floats (Python/bltinmodule.c) | Neumaier's compensated sum. It starts at 0 and adds the compensation only when that is not 0 and is finite, so `[1e308, 1e308, -1e308]` gives `Infinity` and `[-0.0]` gives `0`. `add` and `value` give a running sum; `NeumaierSum.of(values)` sums an iterable. `NeumaierSum.mean(values)` is `sum(values) / len(values)`, and no value throws a `RangeError` (Python's `ZeroDivisionError`, ADR 0003). |
43
43
  | `compareStrings` | the order of two `str` | The order of the Unicode code points, as `sorted()` gives. JavaScript's `<` compares UTF-16 code units, so a character above U+FFFF sorts before U+E000 to U+FFFF there and after them in Python. |
44
44
  | `dumpsJson` | `json.dumps` | The text of `json.dumps`. Each keyword argument is an option: `indent` is `indent`, `separators` is `separators`, `sort_keys` is `sortKeys`, `ensure_ascii` is `ensureAscii` and `allow_nan` is `allowNan`, with CPython's defaults. A dict keeps the order of its `Map`, or `sortKeys` sorts its keys by code point. A float is its `repr()`, and an int its digits. A NaN or an infinity with `allowNan: false`, or an int of more than 4300 digits, throws a `RangeError` (Python's `ValueError`). A fractional `indent`, or a list or dict that holds itself, throws a `TypeError` (ADR 0004). |
45
+ | `floatRound` | `round()` of a float with no digits | The nearest integer, a tie to the even one: `floatRound(2.5)` is `2`, `floatRound(1.5)` is `2`. |
45
46
  | `floatRepr` | `repr()` of a float | The shortest digits, fixed notation for exponents from -4 to 15, and always a fraction: `1.0`, `1e+16`, `1e-05`, `-0.0`, `nan`, `inf`. |
46
47
  | `loadsJson` | `json.loads` | A dict is a `Map` in the order of its keys, and a repeated key keeps its first place and its last value. An int is a `bigint` and a float a `number`, so `1` and `1.0` stay apart. `NaN`, `Infinity` and `-Infinity` are numbers. Text that is not JSON throws a `SyntaxError` (Python's `JSONDecodeError`). An int of more than 4300 digits throws a `RangeError` (Python's `ValueError`). |
47
48
  | `JsonData` | the values of `json.loads` | `null`, `boolean`, `bigint`, `number`, `string`, arrays and `Map`s of them. They are mutable, as in Python, so `Array.isArray` and `instanceof Map` narrow a value. |
@@ -77,6 +78,8 @@ function dumpsJson(value: JsonData, options?: DumpsOptions): string; // throws R
77
78
 
78
79
  function floatRepr(value: number): string;
79
80
 
81
+ function floatRound(value: number): number;
82
+
80
83
  type JsonData =
81
84
  | null
82
85
  | boolean
@@ -0,0 +1,2 @@
1
+ export declare function floatRound(value: number): number;
2
+ //# sourceMappingURL=float-round.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"float-round.d.ts","sourceRoot":"","sources":["../src/float-round.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMhD"}
@@ -0,0 +1,12 @@
1
+ // round() of a float with no digits in CPython (float.__round__): the nearest
2
+ // integer, a tie to the even one.
3
+ export function floatRound(value) {
4
+ const floor = Math.floor(value);
5
+ const fraction = value - floor;
6
+ if (fraction > 0.5)
7
+ return floor + 1;
8
+ if (fraction < 0.5)
9
+ return floor;
10
+ return floor % 2 === 0 ? floor : floor + 1;
11
+ }
12
+ //# sourceMappingURL=float-round.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"float-round.js","sourceRoot":"","sources":["../src/float-round.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,kCAAkC;AAClC,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAChC,MAAM,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC;IAC/B,IAAI,QAAQ,GAAG,GAAG;QAAE,OAAO,KAAK,GAAG,CAAC,CAAC;IACrC,IAAI,QAAQ,GAAG,GAAG;QAAE,OAAO,KAAK,CAAC;IACjC,OAAO,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;AAC7C,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { compareStrings } from './compare-strings.ts';
2
2
  export { type DumpsOptions, dumpsJson } from './dumps-json.ts';
3
+ export { floatRound } from './float-round.ts';
3
4
  export { floatRepr } from './float-repr.ts';
4
5
  export type { JsonData } from './json-data.ts';
5
6
  export { loadsJson } from './loads-json.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,KAAK,cAAc,EACnB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,KAAK,cAAc,EACnB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export { compareStrings } from './compare-strings.js';
2
2
  export { dumpsJson } from './dumps-json.js';
3
+ export { floatRound } from './float-round.js';
3
4
  export { floatRepr } from './float-repr.js';
4
5
  export { loadsJson } from './loads-json.js';
5
6
  export { NeumaierSum } from './neumaier-sum.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAqB,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAEL,gBAAgB,GACjB,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAqB,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAEL,gBAAgB,GACjB,MAAM,0BAA0B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zukhruf/python",
3
- "version": "0.8.272",
3
+ "version": "0.8.274",
4
4
  "description": "The results of CPython 3.12 in JavaScript: the compensated `sum()` of floats, the `repr()` of a float, `json.loads` with the order of keys and ints apart from floats, `json.dumps` with its keyword arguments, and the white space of `str.isspace()`.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -40,7 +40,7 @@
40
40
  "jsonc-parser": "^3.3.1"
41
41
  },
42
42
  "devDependencies": {
43
- "@zukhruf/parameterized-test": "^0.8.272"
43
+ "@zukhruf/parameterized-test": "^0.8.274"
44
44
  },
45
45
  "publishConfig": {
46
46
  "access": "public"