@aglyn/shared-util-tools 1.0.0-beta.143

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.
Files changed (288) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +7 -0
  3. package/package.json +39 -0
  4. package/src/index.d.ts +72 -0
  5. package/src/index.js +87 -0
  6. package/src/index.js.map +1 -0
  7. package/src/lib/apply-mixins.d.ts +24 -0
  8. package/src/lib/apply-mixins.js +31 -0
  9. package/src/lib/apply-mixins.js.map +1 -0
  10. package/src/lib/array/array-copy-deep.d.ts +6 -0
  11. package/src/lib/array/array-copy-deep.js +25 -0
  12. package/src/lib/array/array-copy-deep.js.map +1 -0
  13. package/src/lib/array/array-copy-shallow.d.ts +19 -0
  14. package/src/lib/array/array-copy-shallow.js +20 -0
  15. package/src/lib/array/array-copy-shallow.js.map +1 -0
  16. package/src/lib/array/array-from-length.d.ts +18 -0
  17. package/src/lib/array/array-from-length.js +23 -0
  18. package/src/lib/array/array-from-length.js.map +1 -0
  19. package/src/lib/array/array-from.d.ts +24 -0
  20. package/src/lib/array/array-from.js +26 -0
  21. package/src/lib/array/array-from.js.map +1 -0
  22. package/src/lib/array/array-move-at-index.d.ts +24 -0
  23. package/src/lib/array/array-move-at-index.js +32 -0
  24. package/src/lib/array/array-move-at-index.js.map +1 -0
  25. package/src/lib/array/array-of-entries-to-object.d.ts +23 -0
  26. package/src/lib/array/array-of-entries-to-object.js +26 -0
  27. package/src/lib/array/array-of-entries-to-object.js.map +1 -0
  28. package/src/lib/array/array-overrides.d.ts +29 -0
  29. package/src/lib/array/array-overrides.js +71 -0
  30. package/src/lib/array/array-overrides.js.map +1 -0
  31. package/src/lib/array/array-push-at-index.d.ts +28 -0
  32. package/src/lib/array/array-push-at-index.js +32 -0
  33. package/src/lib/array/array-push-at-index.js.map +1 -0
  34. package/src/lib/array/array-remove-at-index.d.ts +23 -0
  35. package/src/lib/array/array-remove-at-index.js +26 -0
  36. package/src/lib/array/array-remove-at-index.js.map +1 -0
  37. package/src/lib/array/array-remove-item.d.ts +23 -0
  38. package/src/lib/array/array-remove-item.js +27 -0
  39. package/src/lib/array/array-remove-item.js.map +1 -0
  40. package/src/lib/array/array-safe.d.ts +21 -0
  41. package/src/lib/array/array-safe.js +29 -0
  42. package/src/lib/array/array-safe.js.map +1 -0
  43. package/src/lib/array/array-sort-by-deep-property.d.ts +26 -0
  44. package/src/lib/array/array-sort-by-deep-property.js +39 -0
  45. package/src/lib/array/array-sort-by-deep-property.js.map +1 -0
  46. package/src/lib/array/array-sort-by.d.ts +26 -0
  47. package/src/lib/array/array-sort-by.js +36 -0
  48. package/src/lib/array/array-sort-by.js.map +1 -0
  49. package/src/lib/array/array-update-at-index.d.ts +18 -0
  50. package/src/lib/array/array-update-at-index.js +22 -0
  51. package/src/lib/array/array-update-at-index.js.map +1 -0
  52. package/src/lib/array/array-update.d.ts +23 -0
  53. package/src/lib/array/array-update.js +25 -0
  54. package/src/lib/array/array-update.js.map +1 -0
  55. package/src/lib/bitwise/bitwise-has-all-attributes.d.ts +18 -0
  56. package/src/lib/bitwise/bitwise-has-all-attributes.js +21 -0
  57. package/src/lib/bitwise/bitwise-has-all-attributes.js.map +1 -0
  58. package/src/lib/bitwise/bitwise-has-attribute.d.ts +18 -0
  59. package/src/lib/bitwise/bitwise-has-attribute.js +21 -0
  60. package/src/lib/bitwise/bitwise-has-attribute.js.map +1 -0
  61. package/src/lib/bitwise/bitwise-has-only-attributes.d.ts +18 -0
  62. package/src/lib/bitwise/bitwise-has-only-attributes.js +21 -0
  63. package/src/lib/bitwise/bitwise-has-only-attributes.js.map +1 -0
  64. package/src/lib/contrast.d.ts +65 -0
  65. package/src/lib/contrast.js +78 -0
  66. package/src/lib/contrast.js.map +1 -0
  67. package/src/lib/copy-shallow.d.ts +19 -0
  68. package/src/lib/copy-shallow.js +20 -0
  69. package/src/lib/copy-shallow.js.map +1 -0
  70. package/src/lib/copy.d.ts +19 -0
  71. package/src/lib/copy.js +20 -0
  72. package/src/lib/copy.js.map +1 -0
  73. package/src/lib/create-chained-function.d.ts +38 -0
  74. package/src/lib/create-chained-function.js +46 -0
  75. package/src/lib/create-chained-function.js.map +1 -0
  76. package/src/lib/crud.d.ts +46 -0
  77. package/src/lib/crud.js +55 -0
  78. package/src/lib/crud.js.map +1 -0
  79. package/src/lib/css.d.ts +41 -0
  80. package/src/lib/css.js +54 -0
  81. package/src/lib/css.js.map +1 -0
  82. package/src/lib/escape-html.d.ts +38 -0
  83. package/src/lib/escape-html.js +47 -0
  84. package/src/lib/escape-html.js.map +1 -0
  85. package/src/lib/falsy.d.ts +23 -0
  86. package/src/lib/falsy.js +25 -0
  87. package/src/lib/falsy.js.map +1 -0
  88. package/src/lib/get-display-name.d.ts +46 -0
  89. package/src/lib/get-display-name.js +64 -0
  90. package/src/lib/get-display-name.js.map +1 -0
  91. package/src/lib/get-property.d.ts +30 -0
  92. package/src/lib/get-property.js +36 -0
  93. package/src/lib/get-property.js.map +1 -0
  94. package/src/lib/get-static-field.d.ts +23 -0
  95. package/src/lib/get-static-field.js +25 -0
  96. package/src/lib/get-static-field.js.map +1 -0
  97. package/src/lib/guards/index.d.ts +46 -0
  98. package/src/lib/guards/index.js +47 -0
  99. package/src/lib/guards/index.js.map +1 -0
  100. package/src/lib/guards/lib/_has-own-property.d.ts +24 -0
  101. package/src/lib/guards/lib/_has-own-property.js +27 -0
  102. package/src/lib/guards/lib/_has-own-property.js.map +1 -0
  103. package/src/lib/guards/lib/_is-arr-empty.d.ts +23 -0
  104. package/src/lib/guards/lib/_is-arr-empty.js +25 -0
  105. package/src/lib/guards/lib/_is-arr-empty.js.map +1 -0
  106. package/src/lib/guards/lib/_is-arr-of-arr.d.ts +25 -0
  107. package/src/lib/guards/lib/_is-arr-of-arr.js +31 -0
  108. package/src/lib/guards/lib/_is-arr-of-arr.js.map +1 -0
  109. package/src/lib/guards/lib/_is-arr.d.ts +21 -0
  110. package/src/lib/guards/lib/_is-arr.js +23 -0
  111. package/src/lib/guards/lib/_is-arr.js.map +1 -0
  112. package/src/lib/guards/lib/_is-big.d.ts +25 -0
  113. package/src/lib/guards/lib/_is-big.js +27 -0
  114. package/src/lib/guards/lib/_is-big.js.map +1 -0
  115. package/src/lib/guards/lib/_is-bool.d.ts +25 -0
  116. package/src/lib/guards/lib/_is-bool.js +27 -0
  117. package/src/lib/guards/lib/_is-bool.js.map +1 -0
  118. package/src/lib/guards/lib/_is-buff.d.ts +25 -0
  119. package/src/lib/guards/lib/_is-buff.js +29 -0
  120. package/src/lib/guards/lib/_is-buff.js.map +1 -0
  121. package/src/lib/guards/lib/_is-ctor.d.ts +25 -0
  122. package/src/lib/guards/lib/_is-ctor.js +30 -0
  123. package/src/lib/guards/lib/_is-ctor.js.map +1 -0
  124. package/src/lib/guards/lib/_is-empty-str-or-arr.d.ts +25 -0
  125. package/src/lib/guards/lib/_is-empty-str-or-arr.js +29 -0
  126. package/src/lib/guards/lib/_is-empty-str-or-arr.js.map +1 -0
  127. package/src/lib/guards/lib/_is-equality-same-type.d.ts +25 -0
  128. package/src/lib/guards/lib/_is-equality-same-type.js +33 -0
  129. package/src/lib/guards/lib/_is-equality-same-type.js.map +1 -0
  130. package/src/lib/guards/lib/_is-fn-t.d.ts +25 -0
  131. package/src/lib/guards/lib/_is-fn-t.js +27 -0
  132. package/src/lib/guards/lib/_is-fn-t.js.map +1 -0
  133. package/src/lib/guards/lib/_is-length-of.d.ts +47 -0
  134. package/src/lib/guards/lib/_is-length-of.js +49 -0
  135. package/src/lib/guards/lib/_is-length-of.js.map +1 -0
  136. package/src/lib/guards/lib/_is-length.d.ts +25 -0
  137. package/src/lib/guards/lib/_is-length.js +34 -0
  138. package/src/lib/guards/lib/_is-length.js.map +1 -0
  139. package/src/lib/guards/lib/_is-null.d.ts +25 -0
  140. package/src/lib/guards/lib/_is-null.js +27 -0
  141. package/src/lib/guards/lib/_is-null.js.map +1 -0
  142. package/src/lib/guards/lib/_is-num-neg.d.ts +25 -0
  143. package/src/lib/guards/lib/_is-num-neg.js +28 -0
  144. package/src/lib/guards/lib/_is-num-neg.js.map +1 -0
  145. package/src/lib/guards/lib/_is-num-pos.d.ts +25 -0
  146. package/src/lib/guards/lib/_is-num-pos.js +28 -0
  147. package/src/lib/guards/lib/_is-num-pos.js.map +1 -0
  148. package/src/lib/guards/lib/_is-num-t.d.ts +25 -0
  149. package/src/lib/guards/lib/_is-num-t.js +27 -0
  150. package/src/lib/guards/lib/_is-num-t.js.map +1 -0
  151. package/src/lib/guards/lib/_is-num-zero.d.ts +25 -0
  152. package/src/lib/guards/lib/_is-num-zero.js +28 -0
  153. package/src/lib/guards/lib/_is-num-zero.js.map +1 -0
  154. package/src/lib/guards/lib/_is-num.d.ts +26 -0
  155. package/src/lib/guards/lib/_is-num.js +29 -0
  156. package/src/lib/guards/lib/_is-num.js.map +1 -0
  157. package/src/lib/guards/lib/_is-obj-t.d.ts +26 -0
  158. package/src/lib/guards/lib/_is-obj-t.js +28 -0
  159. package/src/lib/guards/lib/_is-obj-t.js.map +1 -0
  160. package/src/lib/guards/lib/_is-obj.d.ts +27 -0
  161. package/src/lib/guards/lib/_is-obj.js +32 -0
  162. package/src/lib/guards/lib/_is-obj.js.map +1 -0
  163. package/src/lib/guards/lib/_is-prim.d.ts +27 -0
  164. package/src/lib/guards/lib/_is-prim.js +35 -0
  165. package/src/lib/guards/lib/_is-prim.js.map +1 -0
  166. package/src/lib/guards/lib/_is-promise-like.d.ts +24 -0
  167. package/src/lib/guards/lib/_is-promise-like.js +28 -0
  168. package/src/lib/guards/lib/_is-promise-like.js.map +1 -0
  169. package/src/lib/guards/lib/_is-str-empty.d.ts +25 -0
  170. package/src/lib/guards/lib/_is-str-empty.js +28 -0
  171. package/src/lib/guards/lib/_is-str-empty.js.map +1 -0
  172. package/src/lib/guards/lib/_is-str-t.d.ts +26 -0
  173. package/src/lib/guards/lib/_is-str-t.js +28 -0
  174. package/src/lib/guards/lib/_is-str-t.js.map +1 -0
  175. package/src/lib/guards/lib/_is-sym-t.d.ts +25 -0
  176. package/src/lib/guards/lib/_is-sym-t.js +27 -0
  177. package/src/lib/guards/lib/_is-sym-t.js.map +1 -0
  178. package/src/lib/guards/lib/_is-und-or-null.d.ts +25 -0
  179. package/src/lib/guards/lib/_is-und-or-null.js +29 -0
  180. package/src/lib/guards/lib/_is-und-or-null.js.map +1 -0
  181. package/src/lib/guards/lib/_is-und-t.d.ts +25 -0
  182. package/src/lib/guards/lib/_is-und-t.js +27 -0
  183. package/src/lib/guards/lib/_is-und-t.js.map +1 -0
  184. package/src/lib/interop-default.d.ts +18 -0
  185. package/src/lib/interop-default.js +21 -0
  186. package/src/lib/interop-default.js.map +1 -0
  187. package/src/lib/length.d.ts +22 -0
  188. package/src/lib/length.js +28 -0
  189. package/src/lib/length.js.map +1 -0
  190. package/src/lib/linear-regex.d.ts +136 -0
  191. package/src/lib/linear-regex.js +1140 -0
  192. package/src/lib/linear-regex.js.map +1 -0
  193. package/src/lib/no-side-effects.d.ts +29 -0
  194. package/src/lib/no-side-effects.js +33 -0
  195. package/src/lib/no-side-effects.js.map +1 -0
  196. package/src/lib/noop.d.ts +21 -0
  197. package/src/lib/noop.js +22 -0
  198. package/src/lib/noop.js.map +1 -0
  199. package/src/lib/normalized.d.ts +164 -0
  200. package/src/lib/normalized.js +232 -0
  201. package/src/lib/normalized.js.map +1 -0
  202. package/src/lib/number/number-from-hexadecimal.d.ts +24 -0
  203. package/src/lib/number/number-from-hexadecimal.js +29 -0
  204. package/src/lib/number/number-from-hexadecimal.js.map +1 -0
  205. package/src/lib/number/number-to-hexadecimal.d.ts +22 -0
  206. package/src/lib/number/number-to-hexadecimal.js +24 -0
  207. package/src/lib/number/number-to-hexadecimal.js.map +1 -0
  208. package/src/lib/number/to-num.d.ts +41 -0
  209. package/src/lib/number/to-num.js +41 -0
  210. package/src/lib/number/to-num.js.map +1 -0
  211. package/src/lib/numeronym.d.ts +41 -0
  212. package/src/lib/numeronym.js +54 -0
  213. package/src/lib/numeronym.js.map +1 -0
  214. package/src/lib/object/object-clone-deep.d.ts +21 -0
  215. package/src/lib/object/object-clone-deep.js +24 -0
  216. package/src/lib/object/object-clone-deep.js.map +1 -0
  217. package/src/lib/object/object-clone.d.ts +21 -0
  218. package/src/lib/object/object-clone.js +24 -0
  219. package/src/lib/object/object-clone.js.map +1 -0
  220. package/src/lib/object/object-delete-property.d.ts +28 -0
  221. package/src/lib/object/object-delete-property.js +32 -0
  222. package/src/lib/object/object-delete-property.js.map +1 -0
  223. package/src/lib/object/object-get-deep-property.d.ts +35 -0
  224. package/src/lib/object/object-get-deep-property.js +40 -0
  225. package/src/lib/object/object-get-deep-property.js.map +1 -0
  226. package/src/lib/object/object-get-keys-and-symbol-properties.d.ts +23 -0
  227. package/src/lib/object/object-get-keys-and-symbol-properties.js +30 -0
  228. package/src/lib/object/object-get-keys-and-symbol-properties.js.map +1 -0
  229. package/src/lib/object/object-remap.d.ts +33 -0
  230. package/src/lib/object/object-remap.js +36 -0
  231. package/src/lib/object/object-remap.js.map +1 -0
  232. package/src/lib/object/object-safe.d.ts +27 -0
  233. package/src/lib/object/object-safe.js +30 -0
  234. package/src/lib/object/object-safe.js.map +1 -0
  235. package/src/lib/object/object-set-deep-property.d.ts +35 -0
  236. package/src/lib/object/object-set-deep-property.js +44 -0
  237. package/src/lib/object/object-set-deep-property.js.map +1 -0
  238. package/src/lib/object/object-update.d.ts +28 -0
  239. package/src/lib/object/object-update.js +32 -0
  240. package/src/lib/object/object-update.js.map +1 -0
  241. package/src/lib/operator/compare.d.ts +26 -0
  242. package/src/lib/operator/compare.js +42 -0
  243. package/src/lib/operator/compare.js.map +1 -0
  244. package/src/lib/operator/definitions.d.ts +184 -0
  245. package/src/lib/operator/definitions.js +110 -0
  246. package/src/lib/operator/definitions.js.map +1 -0
  247. package/src/lib/operator/index.d.ts +19 -0
  248. package/src/lib/operator/index.js +20 -0
  249. package/src/lib/operator/index.js.map +1 -0
  250. package/src/lib/operator/inference.d.ts +66 -0
  251. package/src/lib/operator/inference.js +60 -0
  252. package/src/lib/operator/inference.js.map +1 -0
  253. package/src/lib/secret-box.d.ts +152 -0
  254. package/src/lib/secret-box.js +263 -0
  255. package/src/lib/secret-box.js.map +1 -0
  256. package/src/lib/serialize/base64-isomorphic-decode.d.ts +23 -0
  257. package/src/lib/serialize/base64-isomorphic-decode.js +28 -0
  258. package/src/lib/serialize/base64-isomorphic-decode.js.map +1 -0
  259. package/src/lib/serialize/base64-isomorphic-encode.d.ts +23 -0
  260. package/src/lib/serialize/base64-isomorphic-encode.js +28 -0
  261. package/src/lib/serialize/base64-isomorphic-encode.js.map +1 -0
  262. package/src/lib/serialize/json-deserialize.d.ts +25 -0
  263. package/src/lib/serialize/json-deserialize.js +27 -0
  264. package/src/lib/serialize/json-deserialize.js.map +1 -0
  265. package/src/lib/serialize/json-serialize.d.ts +25 -0
  266. package/src/lib/serialize/json-serialize.js +27 -0
  267. package/src/lib/serialize/json-serialize.js.map +1 -0
  268. package/src/lib/serialize/php-serial-deserialize-from-byte-stream.d.ts +77 -0
  269. package/src/lib/serialize/php-serial-deserialize-from-byte-stream.js +77 -0
  270. package/src/lib/serialize/php-serial-deserialize-from-byte-stream.js.map +1 -0
  271. package/src/lib/serialize/php-serial-is-serialized-byte-stream.d.ts +77 -0
  272. package/src/lib/serialize/php-serial-is-serialized-byte-stream.js +77 -0
  273. package/src/lib/serialize/php-serial-is-serialized-byte-stream.js.map +1 -0
  274. package/src/lib/serialize/php-serial-serialize-to-byte-stream.d.ts +77 -0
  275. package/src/lib/serialize/php-serial-serialize-to-byte-stream.js +77 -0
  276. package/src/lib/serialize/php-serial-serialize-to-byte-stream.js.map +1 -0
  277. package/src/lib/split-display-name.d.ts +36 -0
  278. package/src/lib/split-display-name.js +47 -0
  279. package/src/lib/split-display-name.js.map +1 -0
  280. package/src/lib/str.d.ts +21 -0
  281. package/src/lib/str.js +23 -0
  282. package/src/lib/str.js.map +1 -0
  283. package/src/lib/trim.d.ts +25 -0
  284. package/src/lib/trim.js +28 -0
  285. package/src/lib/trim.js.map +1 -0
  286. package/src/lib/truthy.d.ts +23 -0
  287. package/src/lib/truthy.js +30 -0
  288. package/src/lib/truthy.js.map +1 -0
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ /**
17
+ * Sort iterable by property or index returned from callbackFn
18
+ * @export`
19
+ * @param {T[]} target
20
+ * @param {(item: T) => (string | number)} callbackFn
21
+ * @param thisArg
22
+ * @returns {T[]}
23
+ */ export function arraySortBy(target, callbackFn, thisArg) {
24
+ return target.slice().sort((a, b)=>{
25
+ const propA = callbackFn.call(thisArg, a, target) // callbackFn(a)
26
+ ;
27
+ const propB = callbackFn.call(thisArg, b, target) // prop(b)
28
+ ;
29
+ if (propA > propB) return 1;
30
+ if (propA < propB) return -1;
31
+ return 0;
32
+ });
33
+ }
34
+ export default arraySortBy;
35
+
36
+ //# sourceMappingURL=array-sort-by.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/shared/util/tools/src/lib/array/array-sort-by.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2021 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Sort iterable by property or index returned from callbackFn\n * @export`\n * @param {T[]} target\n * @param {(item: T) => (string | number)} callbackFn\n * @param thisArg\n * @returns {T[]}\n */\nexport function arraySortBy<T>(\n target: T[],\n callbackFn: (item: T, target: T[]) => string | number,\n thisArg?: ThisType<unknown>,\n): T[] {\n return target.slice().sort((a, b) => {\n const propA = callbackFn.call(thisArg, a, target) // callbackFn(a)\n const propB = callbackFn.call(thisArg, b, target) // prop(b)\n if (propA > propB) return 1\n if (propA < propB) return -1\n return 0\n })\n}\n\nexport default arraySortBy\n"],"names":["arraySortBy","target","callbackFn","thisArg","slice","sort","a","b","propA","call","propB"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;CAOC,GACD,OAAO,SAASA,YACdC,MAAW,EACXC,UAAqD,EACrDC,OAA2B;IAE3B,OAAOF,OAAOG,KAAK,GAAGC,IAAI,CAAC,CAACC,GAAGC;QAC7B,MAAMC,QAAQN,WAAWO,IAAI,CAACN,SAASG,GAAGL,QAAQ,gBAAgB;;QAClE,MAAMS,QAAQR,WAAWO,IAAI,CAACN,SAASI,GAAGN,QAAQ,UAAU;;QAC5D,IAAIO,QAAQE,OAAO,OAAO;QAC1B,IAAIF,QAAQE,OAAO,OAAO,CAAC;QAC3B,OAAO;IACT;AACF;AAEA,eAAeV,YAAW"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export declare function arrayUpdateAtIndex<T>(array: Array<T>, index: number | any, elem: T): Array<T>;
18
+ export default arrayUpdateAtIndex;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ export function arrayUpdateAtIndex(array, index, elem) {
17
+ array.splice(index, 1, elem);
18
+ return array;
19
+ }
20
+ export default arrayUpdateAtIndex;
21
+
22
+ //# sourceMappingURL=array-update-at-index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/shared/util/tools/src/lib/array/array-update-at-index.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2022 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\n\nexport function arrayUpdateAtIndex<T>(\n array: Array<T>,\n index: number | any,\n elem: T,\n): Array<T> {\n array.splice(index, 1, elem)\n return array\n}\nexport default arrayUpdateAtIndex\n"],"names":["arrayUpdateAtIndex","array","index","elem","splice"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAID,OAAO,SAASA,mBACdC,KAAe,EACfC,KAAmB,EACnBC,IAAO;IAEPF,MAAMG,MAAM,CAACF,OAAO,GAAGC;IACvB,OAAOF;AACT;AACA,eAAeD,mBAAkB"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Shallow assign, copy and update with multiple arrays
19
+ * @param array - Base array to copy and update
20
+ * @param others - One or more arrays to merge
21
+ */
22
+ export declare function arrayUpdate<T>(array: Array<T>, ...others: (Array<T> | Record<string, unknown>)[]): Array<T>;
23
+ export default arrayUpdate;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ /**
17
+ * Shallow assign, copy and update with multiple arrays
18
+ * @param array - Base array to copy and update
19
+ * @param others - One or more arrays to merge
20
+ */ export function arrayUpdate(array, ...others) {
21
+ return Object.assign(array, ...others);
22
+ }
23
+ export default arrayUpdate;
24
+
25
+ //# sourceMappingURL=array-update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/shared/util/tools/src/lib/array/array-update.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2022 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Shallow assign, copy and update with multiple arrays\n * @param array - Base array to copy and update\n * @param others - One or more arrays to merge\n */\nexport function arrayUpdate<T>(\n array: Array<T>,\n ...others: (Array<T> | Record<string, unknown>)[]\n): Array<T> {\n return Object.assign(array, ...others)\n}\nexport default arrayUpdate\n"],"names":["arrayUpdate","array","others","Object","assign"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;CAIC,GACD,OAAO,SAASA,YACdC,KAAe,EACf,GAAGC,MAA8C;IAEjD,OAAOC,OAAOC,MAAM,CAACH,UAAUC;AACjC;AACA,eAAeF,YAAW"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export declare function bitwiseHasAllAttributes(value: number, attr: number): value is (typeof value | (typeof attr));
18
+ export default bitwiseHasAllAttributes;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ export function bitwiseHasAllAttributes(value, attr) {
17
+ return Boolean(value === (value | attr));
18
+ }
19
+ export default bitwiseHasAllAttributes;
20
+
21
+ //# sourceMappingURL=bitwise-has-all-attributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/shared/util/tools/src/lib/bitwise/bitwise-has-all-attributes.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2021 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nexport function bitwiseHasAllAttributes(\n value: number,\n attr: number\n): value is (typeof value | (typeof attr)) {\n return Boolean(value === (value | (attr)))\n}\nexport default bitwiseHasAllAttributes\n"],"names":["bitwiseHasAllAttributes","value","attr","Boolean"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAGD,OAAO,SAASA,wBACdC,KAAa,EACbC,IAAY;IAEZ,OAAOC,QAAQF,UAAWA,CAAAA,QAASC,IAAI;AACzC;AACA,eAAeF,wBAAuB"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export declare function bitwiseHasAttribute(value: number, attr: number): value is (typeof value & typeof attr);
18
+ export default bitwiseHasAttribute;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ export function bitwiseHasAttribute(value, attr) {
17
+ return Boolean(value & attr);
18
+ }
19
+ export default bitwiseHasAttribute;
20
+
21
+ //# sourceMappingURL=bitwise-has-attribute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/shared/util/tools/src/lib/bitwise/bitwise-has-attribute.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2021 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nexport function bitwiseHasAttribute(\n value: number,\n attr: number,\n): value is (typeof value & typeof attr) {\n return Boolean(value & attr)\n}\nexport default bitwiseHasAttribute\n"],"names":["bitwiseHasAttribute","value","attr","Boolean"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAGD,OAAO,SAASA,oBACdC,KAAa,EACbC,IAAY;IAEZ,OAAOC,QAAQF,QAAQC;AACzB;AACA,eAAeF,oBAAmB"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export declare function bitwiseHasOnlyAttributes(value: number, attr: number): value is typeof attr;
18
+ export default bitwiseHasOnlyAttributes;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ export function bitwiseHasOnlyAttributes(value, attr) {
17
+ return Boolean(value === attr);
18
+ }
19
+ export default bitwiseHasOnlyAttributes;
20
+
21
+ //# sourceMappingURL=bitwise-has-only-attributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/shared/util/tools/src/lib/bitwise/bitwise-has-only-attributes.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2022 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function bitwiseHasOnlyAttributes(\n value: number,\n attr: number,\n): value is typeof attr {\n return Boolean(value === attr)\n}\nexport default bitwiseHasOnlyAttributes\n"],"names":["bitwiseHasOnlyAttributes","value","attr","Boolean"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,OAAO,SAASA,yBACdC,KAAa,EACbC,IAAY;IAEZ,OAAOC,QAAQF,UAAUC;AAC3B;AACA,eAAeF,yBAAwB"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * The WCAG luminance math, with no color library under it.
19
+ *
20
+ * `shared-ui-theme`'s `accessible-shade` owns the same math for the token
21
+ * pipeline, but it decomposes colors through MUI. The two callers here are a
22
+ * server-rendered email page and a console effect, and neither should have to
23
+ * take a theme library to answer "black text or white text on this swatch" —
24
+ * which is how they came to carry a copy each, and how one of the copies came
25
+ * to be wrong.
26
+ *
27
+ * Deliberately NOT re-exported from this library's index — reach it as
28
+ * `@aglyn/shared-util-tools/contrast`. The index note records why.
29
+ */
30
+ /** One sRGB channel (0–255) as linear light. */
31
+ export declare function srgbChannelToLinear(channel: number): number;
32
+ /** WCAG relative luminance, 0 (black) to 1 (white). */
33
+ export declare function relativeLuminanceOfRgb(red: number, green: number, blue: number): number;
34
+ /**
35
+ * `#abc` / `#abcd` / `#rrggbb` / `#rrggbbaa` → channels, or null.
36
+ *
37
+ * Alpha is parsed off and discarded: these callers choose ink for a filled
38
+ * surface, and what the surface composites over is not knowable here.
39
+ */
40
+ export declare function rgbChannelsOfHex(color: string): [red: number, green: number, blue: number] | null;
41
+ /**
42
+ * The luminance at which black text and white text read equally well.
43
+ *
44
+ * Not a taste value and not 0.5. Contrast under WCAG 2.x is
45
+ * `(lighter + 0.05) / (darker + 0.05)`, so black on a background of
46
+ * luminance `L` scores `(L + 0.05) / 0.05` and white on it scores
47
+ * `1.05 / (L + 0.05)`. Those are equal at `L = √(0.05 × 1.05) − 0.05`,
48
+ * which is 0.1791.
49
+ *
50
+ * Splitting at 0.5 instead does not merely round differently, it picks the
51
+ * WRONG ink across the whole middle of the range: on a mid-tone brand color
52
+ * of luminance 0.3 it chooses white, at 3.0:1 — below the AA bar — where
53
+ * black would have given 7.0:1.
54
+ *
55
+ * Written as the derivation rather than as the 0.179 everyone quotes, so the
56
+ * value cannot drift from the rule it comes from.
57
+ */
58
+ export declare const INK_SWITCH_LUMINANCE: number;
59
+ /**
60
+ * Does dark ink read better than light ink on this background?
61
+ *
62
+ * `null` when the color is not a hex literal this can measure, so a caller
63
+ * decides its own fallback rather than being handed a guess.
64
+ */
65
+ export declare function prefersDarkInk(color: string): boolean | null;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ /**
17
+ * The WCAG luminance math, with no color library under it.
18
+ *
19
+ * `shared-ui-theme`'s `accessible-shade` owns the same math for the token
20
+ * pipeline, but it decomposes colors through MUI. The two callers here are a
21
+ * server-rendered email page and a console effect, and neither should have to
22
+ * take a theme library to answer "black text or white text on this swatch" —
23
+ * which is how they came to carry a copy each, and how one of the copies came
24
+ * to be wrong.
25
+ *
26
+ * Deliberately NOT re-exported from this library's index — reach it as
27
+ * `@aglyn/shared-util-tools/contrast`. The index note records why.
28
+ */ /** One sRGB channel (0–255) as linear light. */ export function srgbChannelToLinear(channel) {
29
+ const value = Math.min(255, Math.max(0, channel)) / 255;
30
+ return value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
31
+ }
32
+ /** WCAG relative luminance, 0 (black) to 1 (white). */ export function relativeLuminanceOfRgb(red, green, blue) {
33
+ return 0.2126 * srgbChannelToLinear(red) + 0.7152 * srgbChannelToLinear(green) + 0.0722 * srgbChannelToLinear(blue);
34
+ }
35
+ /**
36
+ * `#abc` / `#abcd` / `#rrggbb` / `#rrggbbaa` → channels, or null.
37
+ *
38
+ * Alpha is parsed off and discarded: these callers choose ink for a filled
39
+ * surface, and what the surface composites over is not knowable here.
40
+ */ export function rgbChannelsOfHex(color) {
41
+ const body = color.trim().replace(/^#/, '');
42
+ const full = body.length === 3 || body.length === 4 ? body.slice(0, 3).split('').map((character)=>character + character).join('') : body.slice(0, 6);
43
+ if (!/^[0-9a-f]{6}$/i.test(full)) return null;
44
+ return [
45
+ parseInt(full.slice(0, 2), 16),
46
+ parseInt(full.slice(2, 4), 16),
47
+ parseInt(full.slice(4, 6), 16)
48
+ ];
49
+ }
50
+ /**
51
+ * The luminance at which black text and white text read equally well.
52
+ *
53
+ * Not a taste value and not 0.5. Contrast under WCAG 2.x is
54
+ * `(lighter + 0.05) / (darker + 0.05)`, so black on a background of
55
+ * luminance `L` scores `(L + 0.05) / 0.05` and white on it scores
56
+ * `1.05 / (L + 0.05)`. Those are equal at `L = √(0.05 × 1.05) − 0.05`,
57
+ * which is 0.1791.
58
+ *
59
+ * Splitting at 0.5 instead does not merely round differently, it picks the
60
+ * WRONG ink across the whole middle of the range: on a mid-tone brand color
61
+ * of luminance 0.3 it chooses white, at 3.0:1 — below the AA bar — where
62
+ * black would have given 7.0:1.
63
+ *
64
+ * Written as the derivation rather than as the 0.179 everyone quotes, so the
65
+ * value cannot drift from the rule it comes from.
66
+ */ export const INK_SWITCH_LUMINANCE = Math.sqrt(1.05 * 0.05) - 0.05;
67
+ /**
68
+ * Does dark ink read better than light ink on this background?
69
+ *
70
+ * `null` when the color is not a hex literal this can measure, so a caller
71
+ * decides its own fallback rather than being handed a guess.
72
+ */ export function prefersDarkInk(color) {
73
+ const channels = rgbChannelsOfHex(color);
74
+ if (!channels) return null;
75
+ return relativeLuminanceOfRgb(...channels) > INK_SWITCH_LUMINANCE;
76
+ }
77
+
78
+ //# sourceMappingURL=contrast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/shared/util/tools/src/lib/contrast.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * The WCAG luminance math, with no color library under it.\n *\n * `shared-ui-theme`'s `accessible-shade` owns the same math for the token\n * pipeline, but it decomposes colors through MUI. The two callers here are a\n * server-rendered email page and a console effect, and neither should have to\n * take a theme library to answer \"black text or white text on this swatch\" —\n * which is how they came to carry a copy each, and how one of the copies came\n * to be wrong.\n *\n * Deliberately NOT re-exported from this library's index — reach it as\n * `@aglyn/shared-util-tools/contrast`. The index note records why.\n */\n\n/** One sRGB channel (0–255) as linear light. */\nexport function srgbChannelToLinear(channel: number): number {\n const value = Math.min(255, Math.max(0, channel)) / 255\n return value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4\n}\n\n/** WCAG relative luminance, 0 (black) to 1 (white). */\nexport function relativeLuminanceOfRgb(\n red: number,\n green: number,\n blue: number,\n): number {\n return (\n 0.2126 * srgbChannelToLinear(red) +\n 0.7152 * srgbChannelToLinear(green) +\n 0.0722 * srgbChannelToLinear(blue)\n )\n}\n\n/**\n * `#abc` / `#abcd` / `#rrggbb` / `#rrggbbaa` → channels, or null.\n *\n * Alpha is parsed off and discarded: these callers choose ink for a filled\n * surface, and what the surface composites over is not knowable here.\n */\nexport function rgbChannelsOfHex(\n color: string,\n): [red: number, green: number, blue: number] | null {\n const body = color.trim().replace(/^#/, '')\n const full =\n body.length === 3 || body.length === 4\n ? body\n .slice(0, 3)\n .split('')\n .map((character) => character + character)\n .join('')\n : body.slice(0, 6)\n if (!/^[0-9a-f]{6}$/i.test(full)) return null\n return [\n parseInt(full.slice(0, 2), 16),\n parseInt(full.slice(2, 4), 16),\n parseInt(full.slice(4, 6), 16),\n ]\n}\n\n/**\n * The luminance at which black text and white text read equally well.\n *\n * Not a taste value and not 0.5. Contrast under WCAG 2.x is\n * `(lighter + 0.05) / (darker + 0.05)`, so black on a background of\n * luminance `L` scores `(L + 0.05) / 0.05` and white on it scores\n * `1.05 / (L + 0.05)`. Those are equal at `L = √(0.05 × 1.05) − 0.05`,\n * which is 0.1791.\n *\n * Splitting at 0.5 instead does not merely round differently, it picks the\n * WRONG ink across the whole middle of the range: on a mid-tone brand color\n * of luminance 0.3 it chooses white, at 3.0:1 — below the AA bar — where\n * black would have given 7.0:1.\n *\n * Written as the derivation rather than as the 0.179 everyone quotes, so the\n * value cannot drift from the rule it comes from.\n */\nexport const INK_SWITCH_LUMINANCE = Math.sqrt(1.05 * 0.05) - 0.05\n\n/**\n * Does dark ink read better than light ink on this background?\n *\n * `null` when the color is not a hex literal this can measure, so a caller\n * decides its own fallback rather than being handed a guess.\n */\nexport function prefersDarkInk(color: string): boolean | null {\n const channels = rgbChannelsOfHex(color)\n if (!channels) return null\n return relativeLuminanceOfRgb(...channels) > INK_SWITCH_LUMINANCE\n}\n"],"names":["srgbChannelToLinear","channel","value","Math","min","max","relativeLuminanceOfRgb","red","green","blue","rgbChannelsOfHex","color","body","trim","replace","full","length","slice","split","map","character","join","test","parseInt","INK_SWITCH_LUMINANCE","sqrt","prefersDarkInk","channels"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;CAYC,GAED,8CAA8C,GAC9C,OAAO,SAASA,oBAAoBC,OAAe;IACjD,MAAMC,QAAQC,KAAKC,GAAG,CAAC,KAAKD,KAAKE,GAAG,CAAC,GAAGJ,YAAY;IACpD,OAAOC,SAAS,UAAUA,QAAQ,QAAQ,AAAC,CAAA,AAACA,CAAAA,QAAQ,KAAI,IAAK,KAAI,KAAM;AACzE;AAEA,qDAAqD,GACrD,OAAO,SAASI,uBACdC,GAAW,EACXC,KAAa,EACbC,IAAY;IAEZ,OACE,SAAST,oBAAoBO,OAC7B,SAASP,oBAAoBQ,SAC7B,SAASR,oBAAoBS;AAEjC;AAEA;;;;;CAKC,GACD,OAAO,SAASC,iBACdC,KAAa;IAEb,MAAMC,OAAOD,MAAME,IAAI,GAAGC,OAAO,CAAC,MAAM;IACxC,MAAMC,OACJH,KAAKI,MAAM,KAAK,KAAKJ,KAAKI,MAAM,KAAK,IACjCJ,KACGK,KAAK,CAAC,GAAG,GACTC,KAAK,CAAC,IACNC,GAAG,CAAC,CAACC,YAAcA,YAAYA,WAC/BC,IAAI,CAAC,MACRT,KAAKK,KAAK,CAAC,GAAG;IACpB,IAAI,CAAC,iBAAiBK,IAAI,CAACP,OAAO,OAAO;IACzC,OAAO;QACLQ,SAASR,KAAKE,KAAK,CAAC,GAAG,IAAI;QAC3BM,SAASR,KAAKE,KAAK,CAAC,GAAG,IAAI;QAC3BM,SAASR,KAAKE,KAAK,CAAC,GAAG,IAAI;KAC5B;AACH;AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMO,uBAAuBrB,KAAKsB,IAAI,CAAC,OAAO,QAAQ,KAAI;AAEjE;;;;;CAKC,GACD,OAAO,SAASC,eAAef,KAAa;IAC1C,MAAMgB,WAAWjB,iBAAiBC;IAClC,IAAI,CAACgB,UAAU,OAAO;IACtB,OAAOrB,0BAA0BqB,YAAYH;AAC/C"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import copyShallow from 'lodash-es/clone.js';
18
+ export { copyShallow };
19
+ export default copyShallow;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ import copyShallow from "lodash-es/clone.js";
17
+ export { copyShallow };
18
+ export default copyShallow;
19
+
20
+ //# sourceMappingURL=copy-shallow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/shared/util/tools/src/lib/copy-shallow.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2022 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport copyShallow from 'lodash-es/clone.js'\n\n\nexport {copyShallow}\nexport default copyShallow\n"],"names":["copyShallow"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,OAAOA,iBAAiB,qBAAoB;AAG5C,SAAQA,WAAW,GAAC;AACpB,eAAeA,YAAW"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import cloneDeep from 'lodash-es/cloneDeep.js';
18
+ export { cloneDeep };
19
+ export default cloneDeep;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ import cloneDeep from "lodash-es/cloneDeep.js";
17
+ export { cloneDeep };
18
+ export default cloneDeep;
19
+
20
+ //# sourceMappingURL=copy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/shared/util/tools/src/lib/copy.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2022 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport cloneDeep from 'lodash-es/cloneDeep.js'\n\nexport { cloneDeep }\nexport default cloneDeep\n"],"names":["cloneDeep"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,OAAOA,eAAe,yBAAwB;AAE9C,SAASA,SAAS,GAAE;AACpB,eAAeA,UAAS"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import type { IndexOf } from './operator/inference';
18
+ export type ChainableFunction<T, A extends any[], R> = {
19
+ (this: T, ...args: A): R;
20
+ };
21
+ /**
22
+ * Safe chained function.
23
+ *
24
+ * Will only create a new function if needed,
25
+ * otherwise will pass back existing functions or null.
26
+ *
27
+ * @example
28
+ * const {onClick} = props
29
+ * const handleOnClick = () => {}
30
+ * const isOpen = false
31
+ * const handleClose = () => {}
32
+ * <element
33
+ * onclick={createChainedFunction(handleOnClick, onClick, isOpen &&
34
+ * handleClose)}
35
+ * />
36
+ */
37
+ export declare function createChainedFunction<T, A extends any[], R>(functions: ChainableFunction<T, A, R>[], thisArg?: T, ...args: IndexOf<A>[]): ChainableFunction<T, A, R>;
38
+ export default createChainedFunction;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ /**
17
+ * Safe chained function.
18
+ *
19
+ * Will only create a new function if needed,
20
+ * otherwise will pass back existing functions or null.
21
+ *
22
+ * @example
23
+ * const {onClick} = props
24
+ * const handleOnClick = () => {}
25
+ * const isOpen = false
26
+ * const handleClose = () => {}
27
+ * <element
28
+ * onclick={createChainedFunction(handleOnClick, onClick, isOpen &&
29
+ * handleClose)}
30
+ * />
31
+ */ export function createChainedFunction(functions, thisArg = null, ...args) {
32
+ return functions.reduce((accumulator, fn)=>{
33
+ return fn == null ? accumulator : chainedFunction;
34
+ function chainedFunction(..._args) {
35
+ const mergedArgs = [
36
+ ..._args,
37
+ ...args
38
+ ];
39
+ accumulator.apply(thisArg || this, mergedArgs);
40
+ return fn.apply(thisArg || this, mergedArgs);
41
+ }
42
+ }, ()=>{});
43
+ }
44
+ export default createChainedFunction;
45
+
46
+ //# sourceMappingURL=create-chained-function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/shared/util/tools/src/lib/create-chained-function.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2023 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { IndexOf } from './operator/inference'\n\nexport type ChainableFunction<T, A extends any[], R> = {\n (this: T, ...args: A): R\n}\n\n/**\n * Safe chained function.\n *\n * Will only create a new function if needed,\n * otherwise will pass back existing functions or null.\n *\n * @example\n * const {onClick} = props\n * const handleOnClick = () => {}\n * const isOpen = false\n * const handleClose = () => {}\n * <element\n * onclick={createChainedFunction(handleOnClick, onClick, isOpen &&\n * handleClose)}\n * />\n */\nexport function createChainedFunction<T, A extends any[], R>(\n functions: ChainableFunction<T, A, R>[],\n thisArg: T = null,\n ...args: IndexOf<A>[]\n): ChainableFunction<T, A, R> {\n return functions.reduce(\n (accumulator, fn) => {\n return fn == null\n ? // When received invalid fn return safe function\n accumulator\n : // Otherwise, build new fn and apply both\n chainedFunction\n\n function chainedFunction(this: T, ..._args: A): R {\n const mergedArgs = [..._args, ...args] as A\n accumulator.apply(thisArg || this, mergedArgs)\n return fn.apply(thisArg || this, mergedArgs)\n }\n },\n (() => {}) as ChainableFunction<T, A, R>,\n )\n}\n\nexport default createChainedFunction\n"],"names":["createChainedFunction","functions","thisArg","args","reduce","accumulator","fn","chainedFunction","_args","mergedArgs","apply"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAQD;;;;;;;;;;;;;;;CAeC,GACD,OAAO,SAASA,sBACdC,SAAuC,EACvCC,UAAa,IAAI,EACjB,GAAGC,IAAkB;IAErB,OAAOF,UAAUG,MAAM,CACrB,CAACC,aAAaC;QACZ,OAAOA,MAAM,OAETD,cAEAE;QAEJ,SAASA,gBAAyB,GAAGC,KAAQ;YAC3C,MAAMC,aAAa;mBAAID;mBAAUL;aAAK;YACtCE,YAAYK,KAAK,CAACR,WAAW,IAAI,EAAEO;YACnC,OAAOH,GAAGI,KAAK,CAACR,WAAW,IAAI,EAAEO;QACnC;IACF,GACC,KAAO;AAEZ;AAEA,eAAeT,sBAAqB"}