ob1 0.80.4 → 0.80.6

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,6 +1,6 @@
1
1
  {
2
2
  "name": "ob1",
3
- "version": "0.80.4",
3
+ "version": "0.80.6",
4
4
  "description": "A small library for working with 0- and 1-based offsets in a type-checked way.",
5
5
  "main": "src/ob1.js",
6
6
  "repository": {
@@ -1,14 +1,3 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- * @oncall react_native
10
- */
11
-
12
1
  "use strict";
13
2
 
14
3
  const { add, add0, add1, get0, get1, inc, neg, sub, sub1 } = require("../ob1");
@@ -33,37 +22,16 @@ module.exports = {
33
22
  inc(FORTY_TWO_1);
34
23
  },
35
24
  testUnsafeOps() {
36
- // $FlowExpectedError - adding two 1-based offsets.
37
25
  add(FORTY_TWO_1, FORTY_TWO_1);
38
-
39
- // $FlowExpectedError - subtracting 1-based offset from 0-based offset.
40
26
  sub(FORTY_TWO_0, FORTY_TWO_1);
41
-
42
- // $FlowExpectedError - direct computations with offsets are disallowed.
43
27
  FORTY_TWO_0 - 1;
44
-
45
- // $FlowExpectedError - direct computations with offsets are disallowed.
46
28
  FORTY_TWO_1 - 1;
47
-
48
- // $FlowExpectedError - extracting a 1-based offset as a 0-based number
49
29
  get0(FORTY_TWO_1);
50
-
51
- // $FlowExpectedError - extracting a 0-based offset as a 1-based number
52
30
  get1(FORTY_TWO_0);
53
-
54
- // $FlowExpectedError - negating a 1-based offset
55
31
  neg(FORTY_TWO_1);
56
-
57
- // $FlowExpectedError - adding 1 to an offset that's already 1-based
58
32
  add1(FORTY_TWO_1);
59
-
60
- // $FlowExpectedError - subtracting 1 from an offset that's already 0-based
61
33
  sub1(FORTY_TWO_0);
62
-
63
- // $FlowExpectedError - extracting an arbitrary number as a 0-based number
64
34
  get0(42);
65
-
66
- // $FlowExpectedError - extracting an arbitrary number as a 1-based number
67
35
  get1(42);
68
36
  },
69
37
  };
package/src/ob1.js CHANGED
@@ -1,65 +1,29 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- * @oncall react_native
10
- */
11
-
12
1
  "use strict";
13
2
 
14
- /* eslint-disable no-redeclare */
15
-
16
- // A type representing 0-based offsets.
17
- // A type representing 1-based offsets.
18
- // Add two offsets or numbers.
19
3
  function add(a, b) {
20
4
  return a + b;
21
5
  }
22
-
23
- // Subtract a number or 0-based offset from a 1/0-based offset.
24
-
25
6
  function sub(a, b) {
26
7
  return a - b;
27
8
  }
28
-
29
- // Get the underlying number of a 0-based offset, casting away the opaque type.
30
-
31
9
  function get0(x) {
32
10
  return x;
33
11
  }
34
-
35
- // Get the underlying number of a 1-based offset, casting away the opaque type.
36
-
37
12
  function get1(x) {
38
13
  return x;
39
14
  }
40
-
41
- // Add 1 to a 0-based offset, thus converting it to 1-based.
42
15
  function add1(x) {
43
16
  return x + 1;
44
17
  }
45
-
46
- // Subtract 1 from a 1-based offset, thus converting it to 0-based.
47
18
  function sub1(x) {
48
19
  return x - 1;
49
20
  }
50
-
51
- // Negate a 0-based offset.
52
21
  function neg(x) {
53
22
  return -x;
54
23
  }
55
-
56
- // Cast a number to a 0-based offset.
57
24
  function add0(x) {
58
25
  return x;
59
26
  }
60
-
61
- // Increment a 0-based offset.
62
-
63
27
  function inc(x) {
64
28
  return x + 1;
65
29
  }