@shakerquiz/utilities 4.0.60 → 4.0.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@shakerquiz/utilities",
4
- "version": "4.0.60",
4
+ "version": "4.0.62",
5
5
  "author": "yurkimus <yurkimus@gmail.com>",
6
6
  "license": "ISC",
7
7
  "repository": {
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @type {typeof Object.hasOwn}
3
+ */
4
+ export const hasOwn = Object.hasOwn
5
+
6
+ /**
7
+ * @param {object} o
8
+ * @param {PropertyKey} v
9
+ *
10
+ * @returns {any}
11
+ */
12
+ export const tryOwn = (o, v) => hasOwn(o, v) ? o[v] : undefined
13
+
14
+ /**
15
+ * @param {object} o
16
+ * @param {PropertyKey} v
17
+ *
18
+ * @throws {TypeError}
19
+ *
20
+ * @returns {any}
21
+ */
22
+ export const getOwn = (o, v) => {
23
+ if (!hasOwn(o, v))
24
+ throw TypeError(`Property '${v}' is not assigned.`)
25
+
26
+ if (tryOwn(o, v) === undefined)
27
+ throw TypeError(`Property '${v}' is not undefined.`)
28
+
29
+ return o[v]
30
+ }
@@ -35,6 +35,7 @@ export const routeBreakdown = maybeRoute =>
35
35
  .split('/')
36
36
  .filter(segment => ['Entity', 'Property', 'Aggregation', 'Operation'].includes(Segment[segment].kind))
37
37
  .map(segment => Segment[segment].singular)
38
+ .join('/')
38
39
 
39
40
  /**
40
41
  * @param {string} maybeRoute