@xylabs/exists 2.7.5 → 2.8.0

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/dist/cjs/index.js CHANGED
@@ -2,15 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.exists = void 0;
4
4
  /**
5
- * Used to type narrow an object which is possibly undefined. Works well
5
+ * Used to type narrow an object which is possibly null or undefined. Works well
6
6
  * with functional Array methods. For example:
7
7
  * @example
8
8
  * const payloads: XyoPayload[] = boundWitness._payloads?.filter(exists) || []
9
- * @param x The object which is potentially undefined
10
- * @returns True if the object is defined, false otherwise
9
+ * @param x The object which is potentially undefined or null
10
+ * @returns False if the object is null/undefined, true otherwise
11
11
  */
12
12
  const exists = (x) => {
13
- return !!x;
13
+ return x === undefined || x === null ? false : true;
14
14
  };
15
15
  exports.exists = exists;
16
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACI,MAAM,MAAM,GAAG,CAAI,CAAY,EAAU,EAAE;IAChD,OAAO,CAAC,CAAC,CAAC,CAAA;AACZ,CAAC,CAAA;AAFY,QAAA,MAAM,UAElB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACI,MAAM,MAAM,GAAG,CAAI,CAAY,EAAU,EAAE;IAChD,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;AACrD,CAAC,CAAA;AAFY,QAAA,MAAM,UAElB"}
package/dist/docs.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "fileName": "index.ts",
18
18
  "line": 9,
19
19
  "character": 13,
20
- "url": "https://github.com/xylabs/sdk-js/blob/09e8e07/packages/exists/src/index.ts#L9"
20
+ "url": "https://github.com/xylabs/sdk-js/blob/9ad4029/packages/exists/src/index.ts#L9"
21
21
  }
22
22
  ],
23
23
  "signatures": [
@@ -31,7 +31,7 @@
31
31
  "summary": [
32
32
  {
33
33
  "kind": "text",
34
- "text": "Used to type narrow an object which is possibly undefined. Works well\nwith functional Array methods. For example:"
34
+ "text": "Used to type narrow an object which is possibly null or undefined. Works well\nwith functional Array methods. For example:"
35
35
  }
36
36
  ],
37
37
  "blockTags": [
@@ -49,7 +49,7 @@
49
49
  "content": [
50
50
  {
51
51
  "kind": "text",
52
- "text": "True if the object is defined, false otherwise"
52
+ "text": "False if the object is null/undefined, true otherwise"
53
53
  }
54
54
  ]
55
55
  }
@@ -77,7 +77,7 @@
77
77
  "summary": [
78
78
  {
79
79
  "kind": "text",
80
- "text": "The object which is potentially undefined"
80
+ "text": "The object which is potentially undefined or null"
81
81
  }
82
82
  ]
83
83
  },
@@ -124,7 +124,7 @@
124
124
  "fileName": "index.ts",
125
125
  "line": 9,
126
126
  "character": 0,
127
- "url": "https://github.com/xylabs/sdk-js/blob/09e8e07/packages/exists/src/index.ts#L9"
127
+ "url": "https://github.com/xylabs/sdk-js/blob/9ad4029/packages/exists/src/index.ts#L9"
128
128
  }
129
129
  ]
130
130
  }
package/dist/esm/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
- * Used to type narrow an object which is possibly undefined. Works well
2
+ * Used to type narrow an object which is possibly null or undefined. Works well
3
3
  * with functional Array methods. For example:
4
4
  * @example
5
5
  * const payloads: XyoPayload[] = boundWitness._payloads?.filter(exists) || []
6
- * @param x The object which is potentially undefined
7
- * @returns True if the object is defined, false otherwise
6
+ * @param x The object which is potentially undefined or null
7
+ * @returns False if the object is null/undefined, true otherwise
8
8
  */
9
9
  export const exists = (x) => {
10
- return !!x;
10
+ return x === undefined || x === null ? false : true;
11
11
  };
12
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAI,CAAY,EAAU,EAAE;IAChD,OAAO,CAAC,CAAC,CAAC,CAAA;AACZ,CAAC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAI,CAAY,EAAU,EAAE;IAChD,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;AACrD,CAAC,CAAA"}
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Used to type narrow an object which is possibly undefined. Works well
2
+ * Used to type narrow an object which is possibly null or undefined. Works well
3
3
  * with functional Array methods. For example:
4
4
  * @example
5
5
  * const payloads: XyoPayload[] = boundWitness._payloads?.filter(exists) || []
6
- * @param x The object which is potentially undefined
7
- * @returns True if the object is defined, false otherwise
6
+ * @param x The object which is potentially undefined or null
7
+ * @returns False if the object is null/undefined, true otherwise
8
8
  */
9
9
  export declare const exists: <T>(x?: T | null | undefined) => x is T;
10
10
  //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -41,7 +41,7 @@
41
41
  "esm"
42
42
  ],
43
43
  "devDependencies": {
44
- "@xylabs/ts-scripts-yarn3": "^2.16.1"
44
+ "@xylabs/ts-scripts-yarn3": "^2.17.13"
45
45
  },
46
46
  "publishConfig": {
47
47
  "access": "public"
@@ -51,5 +51,5 @@
51
51
  "url": "https://github.com/xylabs/sdk-js.git"
52
52
  },
53
53
  "sideEffects": false,
54
- "version": "2.7.5"
54
+ "version": "2.8.0"
55
55
  }
package/src/index.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
- * Used to type narrow an object which is possibly undefined. Works well
2
+ * Used to type narrow an object which is possibly null or undefined. Works well
3
3
  * with functional Array methods. For example:
4
4
  * @example
5
5
  * const payloads: XyoPayload[] = boundWitness._payloads?.filter(exists) || []
6
- * @param x The object which is potentially undefined
7
- * @returns True if the object is defined, false otherwise
6
+ * @param x The object which is potentially undefined or null
7
+ * @returns False if the object is null/undefined, true otherwise
8
8
  */
9
9
  export const exists = <T>(x?: T | null): x is T => {
10
- return !!x
10
+ return x === undefined || x === null ? false : true
11
11
  }