@nordcraft/std-lib 1.0.74 → 1.0.75

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.
@@ -7,6 +7,11 @@ const handler = ([collection, item]) => {
7
7
  return collection.indexOf(item);
8
8
  }
9
9
  if (Array.isArray(collection)) {
10
+ // Short-circuit for primitive types and references
11
+ const fastIndex = collection.indexOf(item);
12
+ if (fastIndex !== -1) {
13
+ return fastIndex;
14
+ }
10
15
  return collection.findIndex((i) => globalThis.toddle.isEqual(i, item));
11
16
  }
12
17
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../formulas/indexOf/handler.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAO,GAA2B,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;IAC9D,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;QACnC,OAAO,UAAU,CAAC,OAAO,CAAC,IAAW,CAAC,CAAA;IACxC,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAC/B,UAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAC5C,CAAA;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AAAA,CACZ,CAAA;AAED,eAAe,OAAO,CAAA"}
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../formulas/indexOf/handler.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAO,GAA2B,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;IAC9D,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;QACnC,OAAO,UAAU,CAAC,OAAO,CAAC,IAAW,CAAC,CAAA;IACxC,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,mDAAmD;QACnD,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAC1C,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC;YACrB,OAAO,SAAS,CAAA;QAClB,CAAC;QAED,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAC/B,UAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAC5C,CAAA;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AAAA,CACZ,CAAA;AAED,eAAe,OAAO,CAAA"}
@@ -3,6 +3,11 @@ const handler = ([collection, item]) => {
3
3
  return collection.lastIndexOf(item);
4
4
  }
5
5
  if (Array.isArray(collection)) {
6
+ // Short-circuit for primitive types and references
7
+ const fastIndex = collection.lastIndexOf(item);
8
+ if (fastIndex !== -1) {
9
+ return fastIndex;
10
+ }
6
11
  return collection.findLastIndex((i) => globalThis.toddle.isEqual(i, item));
7
12
  }
8
13
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../formulas/lastIndexOf/handler.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAA2B,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;IAC9D,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;QACnC,OAAO,UAAU,CAAC,WAAW,CAAC,IAAW,CAAC,CAAA;IAC5C,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,OAAO,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,EAAE,CACnC,UAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAC5C,CAAA;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AAAA,CACZ,CAAA;AAED,eAAe,OAAO,CAAA"}
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../formulas/lastIndexOf/handler.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAA2B,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;IAC9D,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;QACnC,OAAO,UAAU,CAAC,WAAW,CAAC,IAAW,CAAC,CAAA;IAC5C,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,mDAAmD;QACnD,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;QAC9C,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC;YACrB,OAAO,SAAS,CAAA;QAClB,CAAC;QAED,OAAO,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,EAAE,CACnC,UAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAC5C,CAAA;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AAAA,CACZ,CAAA;AAED,eAAe,OAAO,CAAA"}
package/dist/lib.ts CHANGED
@@ -885,7 +885,7 @@
885
885
  "@toddle/last": {
886
886
  "$schema": "../../schemas/libFormula.schema.json",
887
887
  "name": "Last",
888
- "description": "Get the last item in an Array.",
888
+ "description": "Get the last item in an Array or the last character in a String.",
889
889
  "arguments": [
890
890
  {
891
891
  "name": "Array",
@@ -894,13 +894,13 @@
894
894
  "value": []
895
895
  },
896
896
  "type": {
897
- "type": "Array"
897
+ "type": "Array \\| String"
898
898
  },
899
- "description": "The input Array."
899
+ "description": "An array of items or a String."
900
900
  }
901
901
  ],
902
902
  "output": {
903
- "description": "The last item in the Array.",
903
+ "description": "The last item in the Array or the last character in the String.",
904
904
  "type": {
905
905
  "type": "Any"
906
906
  }
@@ -1602,7 +1602,7 @@
1602
1602
  "@toddle/first": {
1603
1603
  "$schema": "../../schemas/libFormula.schema.json",
1604
1604
  "name": "First",
1605
- "description": "Return the first item in an Array.",
1605
+ "description": "Return the first item in an Array or the first character in a String.",
1606
1606
  "arguments": [
1607
1607
  {
1608
1608
  "name": "Array",
@@ -1611,13 +1611,13 @@
1611
1611
  "value": []
1612
1612
  },
1613
1613
  "type": {
1614
- "type": "Array"
1614
+ "type": "Array \\| String"
1615
1615
  },
1616
- "description": "An Array of items."
1616
+ "description": "An Array of items or a String."
1617
1617
  }
1618
1618
  ],
1619
1619
  "output": {
1620
- "description": "The first item in the Array.",
1620
+ "description": "The first item in the Array or the first character in the String.",
1621
1621
  "type": {
1622
1622
  "type": "Any"
1623
1623
  }
@@ -2038,7 +2038,7 @@
2038
2038
  }
2039
2039
  ],
2040
2040
  "output": {
2041
- "description": "Returns an Array of entries for the given input record. The entries are Objects with a “Key” and “Value” property.",
2041
+ "description": "Returns an Array of entries for the given input record. The entries are Objects with a “key” and “value” property.",
2042
2042
  "type": {
2043
2043
  "type": "Array"
2044
2044
  }
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "homepage": "https://github.com/nordcraftengine/nordcraft",
6
6
  "dependencies": {
7
7
  "fast-deep-equal": "3.1.3",
8
- "@nordcraft/core": "1.0.74"
8
+ "@nordcraft/core": "1.0.75"
9
9
  },
10
10
  "devDependencies": {
11
11
  "@types/node": "24.3.1",
@@ -20,5 +20,5 @@
20
20
  "watch": "tsgo --noEmit -w"
21
21
  },
22
22
  "files": ["dist"],
23
- "version": "1.0.74"
23
+ "version": "1.0.75"
24
24
  }