@bessemer/cornerstone 0.5.1 → 0.5.4

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 (282) hide show
  1. package/dist/array.d.ts +57 -0
  2. package/dist/array.d.ts.map +1 -0
  3. package/dist/array.js +137 -0
  4. package/dist/array.js.map +1 -0
  5. package/dist/async.d.ts +59 -0
  6. package/dist/async.d.ts.map +1 -0
  7. package/dist/async.js +62 -0
  8. package/dist/async.js.map +1 -0
  9. package/dist/cache.d.ts +106 -0
  10. package/dist/cache.d.ts.map +1 -0
  11. package/dist/cache.js +112 -0
  12. package/dist/cache.js.map +1 -0
  13. package/dist/combinable.d.ts +16 -0
  14. package/dist/combinable.d.ts.map +1 -0
  15. package/dist/combinable.js +31 -0
  16. package/dist/combinable.js.map +1 -0
  17. package/dist/comparator.d.ts +9 -0
  18. package/dist/comparator.d.ts.map +1 -0
  19. package/dist/comparator.js +76 -0
  20. package/dist/comparator.js.map +1 -0
  21. package/dist/content.d.ts +68 -0
  22. package/dist/content.d.ts.map +1 -0
  23. package/dist/content.js +79 -0
  24. package/dist/content.js.map +1 -0
  25. package/dist/context.d.ts +7 -0
  26. package/dist/context.d.ts.map +1 -0
  27. package/dist/context.js +1 -0
  28. package/dist/context.js.map +1 -0
  29. package/dist/crypto.d.ts +3 -0
  30. package/dist/crypto.d.ts.map +1 -0
  31. package/dist/crypto.js +15 -0
  32. package/dist/crypto.js.map +1 -0
  33. package/dist/date.d.ts +10 -0
  34. package/dist/date.d.ts.map +1 -0
  35. package/dist/date.js +24 -0
  36. package/dist/date.js.map +1 -0
  37. package/dist/duration.d.ts +39 -0
  38. package/dist/duration.d.ts.map +1 -0
  39. package/dist/duration.js +52 -0
  40. package/dist/duration.js.map +1 -0
  41. package/dist/either.d.ts +20 -0
  42. package/dist/either.d.ts.map +1 -0
  43. package/dist/either.js +25 -0
  44. package/dist/either.js.map +1 -0
  45. package/dist/entry.d.ts +7 -0
  46. package/dist/entry.d.ts.map +1 -0
  47. package/dist/entry.js +24 -0
  48. package/dist/entry.js.map +1 -0
  49. package/dist/equalitor.d.ts +5 -0
  50. package/dist/equalitor.d.ts.map +1 -0
  51. package/dist/equalitor.js +10 -0
  52. package/dist/equalitor.js.map +1 -0
  53. package/dist/error-event.d.ts +34 -0
  54. package/dist/error-event.d.ts.map +1 -0
  55. package/dist/error-event.js +91 -0
  56. package/dist/error-event.js.map +1 -0
  57. package/dist/error.d.ts +3 -0
  58. package/dist/error.d.ts.map +1 -0
  59. package/dist/error.js +18 -0
  60. package/dist/error.js.map +1 -0
  61. package/dist/expression/array-expression.d.ts +14 -0
  62. package/dist/expression/array-expression.d.ts.map +1 -0
  63. package/dist/expression/array-expression.js +32 -0
  64. package/dist/expression/array-expression.js.map +1 -0
  65. package/dist/expression/expression-evaluator.d.ts +8 -0
  66. package/dist/expression/expression-evaluator.d.ts.map +1 -0
  67. package/dist/expression/expression-evaluator.js +31 -0
  68. package/dist/expression/expression-evaluator.js.map +1 -0
  69. package/dist/expression/expression.d.ts +54 -0
  70. package/dist/expression/expression.d.ts.map +1 -0
  71. package/dist/expression/expression.js +173 -0
  72. package/dist/expression/expression.js.map +1 -0
  73. package/dist/expression/internal.d.ts +10 -0
  74. package/dist/expression/internal.d.ts.map +1 -0
  75. package/dist/expression/internal.js +28 -0
  76. package/dist/expression/internal.js.map +1 -0
  77. package/dist/expression/numeric-expression.d.ts +79 -0
  78. package/dist/expression/numeric-expression.d.ts.map +1 -0
  79. package/dist/expression/numeric-expression.js +177 -0
  80. package/dist/expression/numeric-expression.js.map +1 -0
  81. package/dist/expression/string-expression.d.ts +24 -0
  82. package/dist/expression/string-expression.d.ts.map +1 -0
  83. package/dist/expression/string-expression.js +41 -0
  84. package/dist/expression/string-expression.js.map +1 -0
  85. package/dist/expression.d.ts +35 -0
  86. package/dist/expression.d.ts.map +1 -0
  87. package/dist/expression.js +12 -0
  88. package/dist/expression.js.map +1 -0
  89. package/dist/function.d.ts +2 -0
  90. package/dist/function.d.ts.map +1 -0
  91. package/dist/function.js +7 -0
  92. package/dist/function.js.map +1 -0
  93. package/dist/glob.d.ts +8 -0
  94. package/dist/glob.d.ts.map +1 -0
  95. package/dist/glob.js +20 -0
  96. package/dist/glob.js.map +1 -0
  97. package/dist/global-variable.d.ts +7 -0
  98. package/dist/global-variable.d.ts.map +1 -0
  99. package/dist/global-variable.js +34 -0
  100. package/dist/global-variable.js.map +1 -0
  101. package/dist/hash.d.ts +11 -0
  102. package/dist/hash.d.ts.map +1 -0
  103. package/dist/hash.js +30 -0
  104. package/dist/hash.js.map +1 -0
  105. package/dist/hex-code.d.ts +5 -0
  106. package/dist/hex-code.d.ts.map +1 -0
  107. package/dist/hex-code.js +7 -0
  108. package/dist/hex-code.js.map +1 -0
  109. package/dist/index.d.ts +41 -0
  110. package/dist/index.d.ts.map +1 -0
  111. package/dist/index.js +82 -0
  112. package/dist/index.js.map +1 -0
  113. package/dist/lazy.d.ts +3 -0
  114. package/dist/lazy.d.ts.map +1 -0
  115. package/dist/lazy.js +13 -0
  116. package/dist/lazy.js.map +1 -0
  117. package/dist/logger.d.ts +30 -0
  118. package/dist/logger.d.ts.map +1 -0
  119. package/dist/logger.js +124 -0
  120. package/dist/logger.js.map +1 -0
  121. package/dist/math.d.ts +22 -0
  122. package/dist/math.d.ts.map +1 -0
  123. package/dist/math.js +123 -0
  124. package/dist/math.js.map +1 -0
  125. package/dist/misc.d.ts +3 -0
  126. package/dist/misc.d.ts.map +1 -0
  127. package/dist/misc.js +21 -0
  128. package/dist/misc.js.map +1 -0
  129. package/dist/object.d.ts +62 -0
  130. package/dist/object.d.ts.map +1 -0
  131. package/dist/object.js +170 -0
  132. package/dist/object.js.map +1 -0
  133. package/dist/patch.d.ts +41 -0
  134. package/dist/patch.d.ts.map +1 -0
  135. package/dist/patch.js +87 -0
  136. package/dist/patch.js.map +1 -0
  137. package/dist/precondition.d.ts +8 -0
  138. package/dist/precondition.d.ts.map +1 -0
  139. package/dist/precondition.js +27 -0
  140. package/dist/precondition.js.map +1 -0
  141. package/dist/promise.d.ts +8 -0
  142. package/dist/promise.d.ts.map +1 -0
  143. package/dist/promise.js +18 -0
  144. package/dist/promise.js.map +1 -0
  145. package/dist/property.d.ts +11 -0
  146. package/dist/property.d.ts.map +1 -0
  147. package/dist/property.js +21 -0
  148. package/dist/property.js.map +1 -0
  149. package/dist/reference.d.ts +22 -0
  150. package/dist/reference.d.ts.map +1 -0
  151. package/dist/reference.js +51 -0
  152. package/dist/reference.js.map +1 -0
  153. package/dist/resource.d.ts +13 -0
  154. package/dist/resource.d.ts.map +1 -0
  155. package/dist/resource.js +27 -0
  156. package/dist/resource.js.map +1 -0
  157. package/dist/result.d.ts +18 -0
  158. package/dist/result.d.ts.map +1 -0
  159. package/dist/result.js +50 -0
  160. package/dist/result.js.map +1 -0
  161. package/dist/retry.d.ts +18 -0
  162. package/dist/retry.d.ts.map +1 -0
  163. package/dist/retry.js +51 -0
  164. package/dist/retry.js.map +1 -0
  165. package/dist/rich-text.d.ts +17 -0
  166. package/dist/rich-text.d.ts.map +1 -0
  167. package/dist/rich-text.js +9 -0
  168. package/dist/rich-text.js.map +1 -0
  169. package/dist/set.d.ts +5 -0
  170. package/dist/set.d.ts.map +1 -0
  171. package/dist/set.js +44 -0
  172. package/dist/set.js.map +1 -0
  173. package/dist/signature.d.ts +9 -0
  174. package/dist/signature.d.ts.map +1 -0
  175. package/dist/signature.js +20 -0
  176. package/dist/signature.js.map +1 -0
  177. package/dist/store.d.ts +40 -0
  178. package/dist/store.d.ts.map +1 -0
  179. package/dist/store.js +50 -0
  180. package/dist/store.js.map +1 -0
  181. package/dist/string.d.ts +40 -0
  182. package/dist/string.d.ts.map +1 -0
  183. package/dist/string.js +154 -0
  184. package/dist/string.js.map +1 -0
  185. package/dist/tag.d.ts +24 -0
  186. package/dist/tag.d.ts.map +1 -0
  187. package/dist/tag.js +50 -0
  188. package/dist/tag.js.map +1 -0
  189. package/dist/types.d.ts +16 -0
  190. package/dist/types.d.ts.map +1 -0
  191. package/dist/types.js +1 -0
  192. package/dist/types.js.map +1 -0
  193. package/dist/ulid.d.ts +8 -0
  194. package/dist/ulid.d.ts.map +1 -0
  195. package/dist/ulid.js +28 -0
  196. package/dist/ulid.js.map +1 -0
  197. package/dist/unit.d.ts +4 -0
  198. package/dist/unit.d.ts.map +1 -0
  199. package/dist/unit.js +6 -0
  200. package/dist/unit.js.map +1 -0
  201. package/dist/uri.d.ts +47 -0
  202. package/dist/uri.d.ts.map +1 -0
  203. package/dist/uri.js +211 -0
  204. package/dist/uri.js.map +1 -0
  205. package/dist/url.d.ts +25 -0
  206. package/dist/url.d.ts.map +1 -0
  207. package/dist/url.js +120 -0
  208. package/dist/url.js.map +1 -0
  209. package/dist/uuid.d.ts +8 -0
  210. package/dist/uuid.d.ts.map +1 -0
  211. package/dist/uuid.js +35 -0
  212. package/dist/uuid.js.map +1 -0
  213. package/dist/zod.d.ts +17 -0
  214. package/dist/zod.d.ts.map +1 -0
  215. package/dist/zod.js +31 -0
  216. package/dist/zod.js.map +1 -0
  217. package/package.json +5 -3
  218. package/jest.config.js +0 -3
  219. package/src/array.ts +0 -142
  220. package/src/async.ts +0 -114
  221. package/src/cache.ts +0 -236
  222. package/src/combinable.ts +0 -40
  223. package/src/comparator.ts +0 -78
  224. package/src/content.ts +0 -138
  225. package/src/context.ts +0 -6
  226. package/src/crypto.ts +0 -11
  227. package/src/date.ts +0 -18
  228. package/src/duration.ts +0 -57
  229. package/src/either.ts +0 -29
  230. package/src/entry.ts +0 -21
  231. package/src/equalitor.ts +0 -12
  232. package/src/error-event.ts +0 -126
  233. package/src/error.ts +0 -16
  234. package/src/expression/array-expression.ts +0 -29
  235. package/src/expression/expression-evaluator.ts +0 -34
  236. package/src/expression/expression.ts +0 -188
  237. package/src/expression/internal.ts +0 -34
  238. package/src/expression/numeric-expression.ts +0 -182
  239. package/src/expression/string-expression.ts +0 -38
  240. package/src/expression.ts +0 -48
  241. package/src/function.ts +0 -3
  242. package/src/glob.ts +0 -19
  243. package/src/global-variable.ts +0 -40
  244. package/src/hash.ts +0 -28
  245. package/src/hex-code.ts +0 -6
  246. package/src/index.ts +0 -82
  247. package/src/lazy.ts +0 -11
  248. package/src/logger.ts +0 -144
  249. package/src/math.ts +0 -132
  250. package/src/misc.ts +0 -22
  251. package/src/object.ts +0 -236
  252. package/src/patch.ts +0 -128
  253. package/src/precondition.ts +0 -25
  254. package/src/promise.ts +0 -16
  255. package/src/property.ts +0 -29
  256. package/src/reference.ts +0 -68
  257. package/src/resource.ts +0 -32
  258. package/src/result.ts +0 -66
  259. package/src/retry.ts +0 -70
  260. package/src/rich-text.ts +0 -24
  261. package/src/set.ts +0 -46
  262. package/src/signature.ts +0 -20
  263. package/src/store.ts +0 -91
  264. package/src/string.ts +0 -173
  265. package/src/tag.ts +0 -68
  266. package/src/types.ts +0 -21
  267. package/src/ulid.ts +0 -28
  268. package/src/unit.ts +0 -4
  269. package/src/uri.ts +0 -321
  270. package/src/url.ts +0 -155
  271. package/src/uuid.ts +0 -37
  272. package/src/zod.ts +0 -24
  273. package/test/comparator.test.ts +0 -1
  274. package/test/expression.test.ts +0 -12
  275. package/test/object.test.ts +0 -104
  276. package/test/patch.test.ts +0 -170
  277. package/test/set.test.ts +0 -20
  278. package/test/string.test.ts +0 -22
  279. package/test/uri.test.ts +0 -111
  280. package/test/url.test.ts +0 -174
  281. package/tsconfig.build.json +0 -13
  282. package/tsup.config.ts +0 -4
@@ -1,104 +0,0 @@
1
- import { Objects } from '@bessemer/cornerstone'
2
-
3
- test('Objects.mergeAll', () => {
4
- expect(
5
- Objects.mergeAll([
6
- { one: 'First Value', two: 'Second Value', three: 'First Value' },
7
- { one: 'Update Value' },
8
- { one: 'Update Value 2', two: null, four: 'Fourth Value' },
9
- { three: undefined },
10
- ])
11
- ).toEqual({
12
- one: 'Update Value 2',
13
- two: null,
14
- three: 'First Value',
15
- four: 'Fourth Value',
16
- })
17
- })
18
-
19
- test('Objects.parsePath', () => {
20
- expect(Objects.parsePath('')).toEqual(Objects.path([]))
21
- expect(Objects.parsePath('this')).toEqual(Objects.path(['this']))
22
- expect(Objects.parsePath('this.is[2].a.path')).toEqual(Objects.path(['this', 'is', 2, 'a', 'path']))
23
- expect(Objects.parsePath('this.is[2].a.path[1]')).toEqual(Objects.path(['this', 'is', 2, 'a', 'path', 1]))
24
- })
25
-
26
- type Address = {
27
- addressLine1: string
28
- addressLine2: string | null
29
- postcode?: number
30
- }
31
-
32
- type Location = {
33
- name: string
34
- address: Address
35
- }
36
-
37
- type Person = {
38
- id: number
39
- name: string
40
- age: number
41
- pets: Array<string>
42
- primaryAddress: Address
43
- residences: Array<Location>
44
- }
45
-
46
- const person: Person = {
47
- id: 1234,
48
- name: 'Bob Bobson',
49
- age: 30,
50
- pets: ['Fishy Fish', 'Yogi', 'General Bismark'],
51
- primaryAddress: {
52
- addressLine1: '123 Fake Street.',
53
- addressLine2: 'Apt 6',
54
- postcode: 77586,
55
- },
56
- residences: [
57
- {
58
- name: 'Winter Estate',
59
- address: {
60
- addressLine1: 'Siberia',
61
- addressLine2: null,
62
- postcode: 34534,
63
- },
64
- },
65
- {
66
- name: 'Summer Palace',
67
- address: {
68
- addressLine1: '456 Palace Avenue',
69
- addressLine2: null,
70
- },
71
- },
72
- ],
73
- }
74
-
75
- test('Objects.getPathValue', () => {
76
- expect(Objects.getPathValue(person, 'id')).toEqual(1234)
77
- expect(Objects.getPathValue(person, 'pets[1]')).toEqual('Yogi')
78
- expect(Objects.getPathValue(person, 'primaryAddress.addressLine1')).toEqual('123 Fake Street.')
79
- expect(Objects.getPathValue(person, 'residences[0].address')).toEqual({
80
- addressLine1: 'Siberia',
81
- addressLine2: null,
82
- postcode: 34534,
83
- })
84
- expect(Objects.getPathValue(person, 'residences[2].address')).toEqual(undefined)
85
- expect(Objects.getPathValue(person, 'residences.address[0]')).toEqual(undefined)
86
- })
87
-
88
- test('Objects.applyPathValue', () => {
89
- {
90
- const modifiedPerson = Objects.applyPathValue(person, 'primaryAddress.addressLine1', 'Changed!') as Person
91
- expect(modifiedPerson.primaryAddress.addressLine1).toEqual('Changed!')
92
- expect(person.primaryAddress.addressLine1).toEqual('123 Fake Street.')
93
- }
94
-
95
- {
96
- const modifiedPerson = Objects.applyPathValue(person, 'residences[0].address', 'Changed!') as Person
97
- expect(modifiedPerson.residences[0]!.address).toEqual('Changed!')
98
- }
99
-
100
- {
101
- const modifiedPerson = Objects.applyPathValue(person, 'residences[3].address', 'Changed!') as Person
102
- expect(modifiedPerson).toEqual(undefined)
103
- }
104
- })
@@ -1,170 +0,0 @@
1
- import { Patches } from '@bessemer/cornerstone'
2
- import { Expressions } from '@bessemer/cornerstone/expression'
3
-
4
- test('Patch Numbers', () => {
5
- {
6
- const value = Patches.resolve(5, [Patches.sum(1), Patches.sum(2), Patches.sum(3)], Expressions.defaultEvaluator())
7
- expect(value).toEqual(11)
8
- }
9
-
10
- {
11
- const value = Patches.resolve(5, [Patches.multiply(2), Patches.sum(2), Patches.multiply(2)], Expressions.defaultEvaluator())
12
- expect(value).toEqual(24)
13
- }
14
-
15
- {
16
- const value = Patches.resolve(5, [Patches.set(2), Patches.sum(2), Patches.set(5)], Expressions.defaultEvaluator())
17
- expect(value).toEqual(5)
18
- }
19
- })
20
-
21
- test('Patch Objects', () => {
22
- type Address = {
23
- addressLine1: string
24
- addressLine2: string | null
25
- postcode?: number
26
- }
27
-
28
- type Location = {
29
- name: string
30
- address: Address
31
- }
32
-
33
- type Person = {
34
- id: number
35
- name: string
36
- age: number
37
- pets: Array<string>
38
- primaryAddress: Address
39
- residences: Array<Location>
40
- }
41
-
42
- const originalPerson: Person = {
43
- id: 1234,
44
- name: 'Bob Bobson',
45
- age: 30,
46
- pets: ['Fishy Fish', 'Yogi', 'General Bismark'],
47
- primaryAddress: {
48
- addressLine1: '123 Fake Street.',
49
- addressLine2: 'Apt 6',
50
- postcode: 77586,
51
- },
52
- residences: [
53
- {
54
- name: 'Winter Estate',
55
- address: {
56
- addressLine1: 'Siberia',
57
- addressLine2: null,
58
- postcode: 34534,
59
- },
60
- },
61
- {
62
- name: 'Summer Palace',
63
- address: {
64
- addressLine1: '456 Palace Avenue',
65
- addressLine2: null,
66
- },
67
- },
68
- ],
69
- }
70
-
71
- {
72
- const updatedPerson = Patches.resolve(
73
- originalPerson,
74
- [
75
- Patches.patch({
76
- name: 'Bobby',
77
- age: Patches.multiply(2),
78
- pets: Patches.set(['Burly Bear']),
79
- primaryAddress: {
80
- addressLine2: 'New Apartment',
81
- },
82
- }),
83
- ],
84
- Expressions.defaultEvaluator()
85
- )
86
-
87
- expect(originalPerson.name).toEqual('Bob Bobson')
88
- expect(updatedPerson.id).toEqual(originalPerson.id)
89
- expect(updatedPerson.primaryAddress.addressLine1).toEqual(originalPerson.primaryAddress.addressLine1)
90
-
91
- expect(updatedPerson.name).toEqual('Bobby')
92
- expect(updatedPerson.age).toEqual(60)
93
- expect(updatedPerson.primaryAddress.addressLine2).toEqual('New Apartment')
94
- expect(updatedPerson.pets).toEqual(['Burly Bear'])
95
- }
96
-
97
- {
98
- const updatedPerson = Patches.resolve(
99
- originalPerson,
100
- [
101
- Patches.patch({
102
- pets: Patches.concatenate(['Burly Bear']),
103
- primaryAddress: Patches.set({
104
- addressLine1: 'Another Street',
105
- addressLine2: 'Apt 7',
106
- }),
107
- }),
108
- ],
109
- Expressions.defaultEvaluator()
110
- )
111
-
112
- expect(updatedPerson.pets).toEqual([...originalPerson.pets, 'Burly Bear'])
113
- expect(updatedPerson.primaryAddress).toEqual({
114
- addressLine1: 'Another Street',
115
- addressLine2: 'Apt 7',
116
- })
117
- }
118
-
119
- {
120
- const updatedPerson = Patches.resolve(
121
- originalPerson,
122
- [
123
- Patches.patch({
124
- residences: [
125
- {
126
- name: 'Winter Chalet',
127
- },
128
- {
129
- address: {
130
- addressLine1: 'Address Line 1 Changed!',
131
- },
132
- },
133
- ],
134
- }),
135
- ],
136
- Expressions.defaultEvaluator()
137
- )
138
-
139
- expect(updatedPerson.residences.length).toEqual(2)
140
- expect(updatedPerson.residences[0]!.name).toEqual('Winter Chalet')
141
- expect(updatedPerson.residences[0]!.address.addressLine1).toEqual('Siberia')
142
- expect(updatedPerson.residences[1]!.name).toEqual('Summer Palace')
143
- expect(updatedPerson.residences[1]!.address.addressLine1).toEqual('Address Line 1 Changed!')
144
- }
145
-
146
- {
147
- const updatedPerson = Patches.resolve(
148
- originalPerson,
149
- [
150
- Patches.patch({
151
- residences: [
152
- {},
153
- {
154
- address: Patches.set({
155
- addressLine1: 'Liberia',
156
- addressLine2: null,
157
- }),
158
- },
159
- ],
160
- }),
161
- ],
162
- Expressions.defaultEvaluator()
163
- )
164
-
165
- expect(updatedPerson.residences[1]!.address).toEqual({
166
- addressLine1: 'Liberia',
167
- addressLine2: null,
168
- })
169
- }
170
- })
package/test/set.test.ts DELETED
@@ -1,20 +0,0 @@
1
- import { Sets } from '@bessemer/cornerstone'
2
-
3
- test('Sets.permute', () => {
4
- expect(Sets.permute(['a', 'b', 'c'])).toEqual([
5
- ['a', 'b', 'c'],
6
- ['a', 'c', 'b'],
7
- ['b', 'a', 'c'],
8
- ['b', 'c', 'a'],
9
- ['c', 'a', 'b'],
10
- ['c', 'b', 'a'],
11
- ])
12
- })
13
-
14
- test('Sets.properPowerSet', () => {
15
- expect(Sets.properPowerSet(['a', 'b', 'c'])).toEqual([['a'], ['b'], ['a', 'b'], ['c'], ['a', 'c'], ['b', 'c'], ['a', 'b', 'c']])
16
- })
17
-
18
- test('Sets.powerSet', () => {
19
- expect(Sets.powerSet(['a', 'b', 'c'])).toEqual([[], ['a'], ['b'], ['a', 'b'], ['c'], ['a', 'c'], ['b', 'c'], ['a', 'b', 'c']])
20
- })
@@ -1,22 +0,0 @@
1
- import { Strings } from '@bessemer/cornerstone'
2
-
3
- // JOHN need to get test suite to actually run again
4
- test('Strings.splitFirst', () => {
5
- expect(Strings.splitFirst('this.is.a.string.', '.')).toEqual({ selection: 'this', separator: '.', rest: 'is.a.string.' })
6
- expect(Strings.splitFirst('', '/')).toEqual({ selection: null, separator: null, rest: '' })
7
- expect(Strings.splitFirst('thisisastring', '.')).toEqual({ selection: null, separator: null, rest: 'thisisastring' })
8
- expect(Strings.splitFirst('this123is123a123string', '123')).toEqual({ selection: 'this', separator: '123', rest: 'is123a123string' })
9
- expect(Strings.splitFirst('/test', '/')).toEqual({ selection: '', separator: '/', rest: 'test' })
10
- expect(Strings.splitFirst('test/', '/')).toEqual({ selection: 'test', separator: '/', rest: '' })
11
- expect(Strings.splitFirst('//test/', '/')).toEqual({ selection: '', separator: '/', rest: '/test/' })
12
- })
13
-
14
- test('Strings.splitLast', () => {
15
- expect(Strings.splitLast('.this.is.a.string', '.')).toEqual({ selection: 'string', separator: '.', rest: '.this.is.a' })
16
- expect(Strings.splitLast('', '/')).toEqual({ selection: null, separator: null, rest: '' })
17
- expect(Strings.splitLast('thisisastring', '.')).toEqual({ selection: null, separator: null, rest: 'thisisastring' })
18
- expect(Strings.splitLast('this123is123a123string', '123')).toEqual({ selection: 'string', separator: '123', rest: 'this123is123a' })
19
- expect(Strings.splitLast('/test', '/')).toEqual({ selection: 'test', separator: '/', rest: '' })
20
- expect(Strings.splitLast('test/', '/')).toEqual({ selection: '', separator: '/', rest: 'test' })
21
- expect(Strings.splitLast('//test/', '/')).toEqual({ selection: '', separator: '/', rest: '//test' })
22
- })
package/test/uri.test.ts DELETED
@@ -1,111 +0,0 @@
1
- import { Uris } from '@bessemer/cornerstone'
2
-
3
- test('Uris.parse / Uris.build', () => {
4
- expect(Uris.parse('tel:+1-816-555-1212')).toEqual(
5
- Uris.build({
6
- scheme: 'tel',
7
- location: {
8
- path: '+1-816-555-1212',
9
- },
10
- })
11
- )
12
-
13
- expect(Uris.parse('tel:+1-816-555-1212?#')).toEqual(
14
- Uris.build({
15
- scheme: 'tel',
16
- location: '+1-816-555-1212',
17
- })
18
- )
19
-
20
- expect(Uris.parse('tel:+1-816-555-1212?#fragment')).toEqual(
21
- Uris.build({
22
- scheme: 'tel',
23
- location: {
24
- path: '+1-816-555-1212',
25
- fragment: 'fragment',
26
- },
27
- })
28
- )
29
-
30
- expect(Uris.parse('telnet://192.0.2.16:80/')).toEqual(
31
- Uris.build({
32
- scheme: 'telnet',
33
- host: {
34
- value: '192.0.2.16',
35
- port: 80,
36
- },
37
- location: {
38
- path: '/',
39
- },
40
- })
41
- )
42
-
43
- expect(Uris.parse('telnet://192.0.2.16:80')).toEqual(
44
- Uris.build({
45
- scheme: 'telnet',
46
- host: '192.0.2.16:80',
47
- location: '',
48
- })
49
- )
50
-
51
- expect(Uris.parse('urn:oasis:names:specification:docbook:dtd:xml:4.1.2')).toEqual(
52
- Uris.build({
53
- scheme: 'urn',
54
- location: 'oasis:names:specification:docbook:dtd:xml:4.1.2',
55
- })
56
- )
57
-
58
- expect(Uris.parse('news:comp.infosystems.www.servers.unix')).toEqual(
59
- Uris.build({
60
- scheme: 'news',
61
- location: {
62
- path: 'comp.infosystems.www.servers.unix',
63
- },
64
- })
65
- )
66
-
67
- expect(Uris.parse('ldap://[2001:db8::7]/c=GB?objectClass?one')).toEqual(
68
- Uris.build({
69
- scheme: 'ldap',
70
- host: {
71
- value: '[2001:db8::7]',
72
- },
73
- location: {
74
- path: '/c=GB',
75
- query: 'objectClass?one',
76
- },
77
- })
78
- )
79
-
80
- expect(Uris.parse('ldap://[2001:db8::7]:389/c=GB?objectClass?one')).toEqual(
81
- Uris.build({
82
- scheme: 'ldap',
83
- host: {
84
- value: '[2001:db8::7]',
85
- port: 389,
86
- },
87
- location: {
88
- path: '/c=GB',
89
- query: 'objectClass?one',
90
- },
91
- })
92
- )
93
-
94
- expect(Uris.parse('https://john.doe@www.example.com:1234/forum/questions/?tag=networking&order=newest#:~:text=whatever')).toEqual(
95
- Uris.build({
96
- scheme: 'https',
97
- authentication: {
98
- principal: 'john.doe',
99
- },
100
- host: {
101
- value: 'www.example.com',
102
- port: 1234,
103
- },
104
- location: {
105
- path: '/forum/questions/',
106
- query: 'tag=networking&order=newest',
107
- fragment: ':~:text=whatever',
108
- },
109
- })
110
- )
111
- })
package/test/url.test.ts DELETED
@@ -1,174 +0,0 @@
1
- import { Urls } from '@bessemer/cornerstone'
2
-
3
- test('Urls.parse / Urls.build', () => {
4
- {
5
- expect(Urls.parse('https://www.google.com')).toEqual(
6
- Urls.build({
7
- scheme: 'https',
8
- host: 'www.google.com',
9
- })
10
- )
11
- }
12
- {
13
- expect(Urls.parse('https://www.google.com/')).toEqual(
14
- Urls.build({
15
- scheme: 'https',
16
- host: 'www.google.com',
17
- })
18
- )
19
- }
20
-
21
- // TODO i think we should try and support these URLs without having to have the double slash
22
- {
23
- expect(Urls.parse('//www.google.com')).toEqual(
24
- Urls.build({
25
- host: 'www.google.com',
26
- })
27
- )
28
- }
29
-
30
- {
31
- expect(Urls.parse('//www.google.com/')).toEqual(
32
- Urls.build({
33
- host: 'www.google.com',
34
- })
35
- )
36
- }
37
-
38
- {
39
- expect(Urls.parse('http://localhost:8080')).toEqual(
40
- Urls.build({
41
- scheme: 'http',
42
- host: {
43
- value: 'localhost',
44
- port: 8080,
45
- },
46
- })
47
- )
48
- }
49
-
50
- {
51
- expect(Urls.parse('http://localhost:8080/')).toEqual(
52
- Urls.build({
53
- scheme: 'http',
54
- host: 'localhost:8080',
55
- })
56
- )
57
- }
58
- {
59
- expect(Urls.parse('//localhost:8080')).toEqual(
60
- Urls.build({
61
- host: {
62
- value: 'localhost',
63
- port: 8080,
64
- },
65
- })
66
- )
67
- }
68
- {
69
- expect(Urls.parse('//localhost:8080/')).toEqual(
70
- Urls.build({
71
- host: {
72
- value: 'localhost',
73
- port: 8080,
74
- },
75
- })
76
- )
77
- }
78
-
79
- {
80
- expect(Urls.parse('https://john.lutteringer:password123@www.google.com')).toEqual(
81
- Urls.build({
82
- scheme: 'https',
83
- host: 'www.google.com',
84
- authentication: {
85
- principal: 'john.lutteringer',
86
- password: 'password123',
87
- },
88
- })
89
- )
90
- }
91
-
92
- {
93
- expect(Urls.parse('https://john.lutteringer:password123@www.google.com/')).toEqual(
94
- Urls.build({
95
- scheme: 'https',
96
- host: 'www.google.com',
97
- authentication: 'john.lutteringer:password123',
98
- })
99
- )
100
- }
101
-
102
- {
103
- expect(Urls.parse('https://john.lutteringer@www.google.com/')).toEqual(
104
- Urls.build({
105
- scheme: 'https',
106
- host: 'www.google.com',
107
- authentication: 'john.lutteringer',
108
- })
109
- )
110
- }
111
-
112
- {
113
- expect(Urls.parse('john.lutteringer@www.google.com')).toEqual(
114
- Urls.build({
115
- host: 'www.google.com',
116
- authentication: {
117
- principal: 'john.lutteringer',
118
- },
119
- })
120
- )
121
- }
122
-
123
- {
124
- expect(Urls.parse('//john.lutteringer:password123@www.google.com')).toEqual(
125
- Urls.build({
126
- host: 'www.google.com',
127
- authentication: {
128
- principal: 'john.lutteringer',
129
- password: 'password123',
130
- },
131
- })
132
- )
133
- }
134
-
135
- {
136
- expect(Urls.parse('//www.google.com?q=Search%20Query')).toEqual(
137
- Urls.build({
138
- host: 'www.google.com',
139
- location: {
140
- path: '',
141
- parameters: {
142
- q: 'Search Query',
143
- },
144
- },
145
- })
146
- )
147
- }
148
-
149
- {
150
- expect(Urls.parse('/search?q=Search%20Query')).toEqual(
151
- Urls.build({
152
- location: {
153
- path: '/search',
154
- parameters: {
155
- q: 'Search Query',
156
- },
157
- },
158
- })
159
- )
160
- }
161
-
162
- {
163
- expect(Urls.parse('search?q=Search%20Query')).toEqual(
164
- Urls.build({
165
- location: {
166
- path: 'search',
167
- parameters: {
168
- q: 'Search Query',
169
- },
170
- },
171
- })
172
- )
173
- }
174
- })
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.lib.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- "rootDir": "src",
6
- "baseUrl": ".",
7
- "paths": {
8
- "@bessemer/cornerstone": ["src"],
9
- "@bessemer/cornerstone/*": ["src/*"]
10
- }
11
- },
12
- "exclude": ["dist", "node_modules", "test" ,"tsup.config.ts", "jest.config.js"]
13
- }
package/tsup.config.ts DELETED
@@ -1,4 +0,0 @@
1
- import { defineConfig } from 'tsup'
2
- import { Config } from '../tsup.base.js'
3
-
4
- export default defineConfig(Config)