@rcompat/is 0.1.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.
Files changed (64) hide show
  1. package/LICENSE +19 -0
  2. package/lib/private/blank.d.ts +2 -0
  3. package/lib/private/blank.js +4 -0
  4. package/lib/private/boolish.d.ts +3 -0
  5. package/lib/private/boolish.js +4 -0
  6. package/lib/private/defined.d.ts +2 -0
  7. package/lib/private/defined.js +4 -0
  8. package/lib/private/empty.d.ts +2 -0
  9. package/lib/private/empty.js +16 -0
  10. package/lib/private/falsy.d.ts +2 -0
  11. package/lib/private/falsy.js +4 -0
  12. package/lib/private/finite.d.ts +2 -0
  13. package/lib/private/finite.js +10 -0
  14. package/lib/private/integer.d.ts +2 -0
  15. package/lib/private/integer.js +10 -0
  16. package/lib/private/nan.d.ts +2 -0
  17. package/lib/private/nan.js +4 -0
  18. package/lib/private/negative-integer.d.ts +2 -0
  19. package/lib/private/negative-integer.js +5 -0
  20. package/lib/private/newable.d.ts +3 -0
  21. package/lib/private/newable.js +12 -0
  22. package/lib/private/nil.d.ts +2 -0
  23. package/lib/private/nil.js +4 -0
  24. package/lib/private/nullish.d.ts +3 -0
  25. package/lib/private/nullish.js +4 -0
  26. package/lib/private/numeric.d.ts +2 -0
  27. package/lib/private/numeric.js +12 -0
  28. package/lib/private/positive-integer.d.ts +2 -0
  29. package/lib/private/positive-integer.js +5 -0
  30. package/lib/private/safe-integer.d.ts +2 -0
  31. package/lib/private/safe-integer.js +6 -0
  32. package/lib/private/truthy.d.ts +2 -0
  33. package/lib/private/truthy.js +4 -0
  34. package/lib/private/uint.d.ts +2 -0
  35. package/lib/private/uint.js +5 -0
  36. package/lib/public/blank.d.ts +2 -0
  37. package/lib/public/blank.js +2 -0
  38. package/lib/public/boolish.d.ts +2 -0
  39. package/lib/public/boolish.js +2 -0
  40. package/lib/public/defined.d.ts +2 -0
  41. package/lib/public/defined.js +2 -0
  42. package/lib/public/empty.d.ts +2 -0
  43. package/lib/public/empty.js +2 -0
  44. package/lib/public/falsy.d.ts +2 -0
  45. package/lib/public/falsy.js +2 -0
  46. package/lib/public/finite.d.ts +2 -0
  47. package/lib/public/finite.js +2 -0
  48. package/lib/public/integer.d.ts +2 -0
  49. package/lib/public/integer.js +2 -0
  50. package/lib/public/nan.d.ts +2 -0
  51. package/lib/public/nan.js +2 -0
  52. package/lib/public/newable.d.ts +2 -0
  53. package/lib/public/newable.js +2 -0
  54. package/lib/public/nullish.d.ts +2 -0
  55. package/lib/public/nullish.js +2 -0
  56. package/lib/public/numeric.d.ts +2 -0
  57. package/lib/public/numeric.js +2 -0
  58. package/lib/public/safe-integer.d.ts +2 -0
  59. package/lib/public/safe-integer.js +2 -0
  60. package/lib/public/truthy.d.ts +2 -0
  61. package/lib/public/truthy.js +2 -0
  62. package/lib/public/uint.d.ts +2 -0
  63. package/lib/public/uint.js +2 -0
  64. package/package.json +36 -0
package/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) Terrablue <terrablue@proton.me> and contributors.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ export default function isBlank(x: unknown): x is string;
2
+ //# sourceMappingURL=blank.d.ts.map
@@ -0,0 +1,4 @@
1
+ export default function isBlank(x) {
2
+ return typeof x === "string" && /^\s*$/.test(x);
3
+ }
4
+ //# sourceMappingURL=blank.js.map
@@ -0,0 +1,3 @@
1
+ import type Boolish from "@rcompat/type/Boolish";
2
+ export default function isBoolish(x: unknown): x is Boolish;
3
+ //# sourceMappingURL=boolish.d.ts.map
@@ -0,0 +1,4 @@
1
+ export default function isBoolish(x) {
2
+ return x === "true" || x === "false";
3
+ }
4
+ //# sourceMappingURL=boolish.js.map
@@ -0,0 +1,2 @@
1
+ export default function isDefined(x: unknown): x is {} | null;
2
+ //# sourceMappingURL=defined.d.ts.map
@@ -0,0 +1,4 @@
1
+ export default function isDefined(x) {
2
+ return x !== undefined;
3
+ }
4
+ //# sourceMappingURL=defined.js.map
@@ -0,0 +1,2 @@
1
+ export default function isEmpty(x: unknown): boolean;
2
+ //# sourceMappingURL=empty.d.ts.map
@@ -0,0 +1,16 @@
1
+ export default function isEmpty(x) {
2
+ if (typeof x === "string" || Array.isArray(x))
3
+ return x.length === 0;
4
+ if (x instanceof Set || x instanceof Map)
5
+ return x.size === 0;
6
+ if (typeof x === "object" && x !== null)
7
+ return Object.keys(x).length === 0;
8
+ if (x && typeof x === "object") {
9
+ const prototype = Object.getPrototypeOf(x);
10
+ if (prototype === Object.prototype || prototype === null) {
11
+ return Object.keys(x).length === 0;
12
+ }
13
+ }
14
+ return false;
15
+ }
16
+ //# sourceMappingURL=empty.js.map
@@ -0,0 +1,2 @@
1
+ export default function isFalsy(x: unknown): boolean;
2
+ //# sourceMappingURL=falsy.d.ts.map
@@ -0,0 +1,4 @@
1
+ export default function isFalsy(x) {
2
+ return !x;
3
+ }
4
+ //# sourceMappingURL=falsy.js.map
@@ -0,0 +1,2 @@
1
+ export default function isFinite(x: unknown): x is bigint | number;
2
+ //# sourceMappingURL=finite.d.ts.map
@@ -0,0 +1,10 @@
1
+ export default function isFinite(x) {
2
+ if (typeof x === "bigint") {
3
+ return true;
4
+ }
5
+ if (typeof x === "number") {
6
+ return Number.isFinite(x);
7
+ }
8
+ return false;
9
+ }
10
+ //# sourceMappingURL=finite.js.map
@@ -0,0 +1,2 @@
1
+ export default function isInteger(x: unknown): x is number | bigint;
2
+ //# sourceMappingURL=integer.d.ts.map
@@ -0,0 +1,10 @@
1
+ export default function isInteger(x) {
2
+ if (typeof x === "bigint") {
3
+ return true;
4
+ }
5
+ if (typeof x === "number") {
6
+ return Number.isInteger(x);
7
+ }
8
+ return false;
9
+ }
10
+ //# sourceMappingURL=integer.js.map
@@ -0,0 +1,2 @@
1
+ export default function isNaN(x: unknown): x is number;
2
+ //# sourceMappingURL=nan.d.ts.map
@@ -0,0 +1,4 @@
1
+ export default function isNaN(x) {
2
+ return typeof x === "number" && Number.isNaN(x);
3
+ }
4
+ //# sourceMappingURL=nan.js.map
@@ -0,0 +1,2 @@
1
+ export default function isNegativeInteger(x: unknown): x is number | bigint;
2
+ //# sourceMappingURL=negative-integer.d.ts.map
@@ -0,0 +1,5 @@
1
+ import isInteger from "#integer";
2
+ export default function isNegativeInteger(x) {
3
+ return isInteger(x) && BigInt(x) < 0n;
4
+ }
5
+ //# sourceMappingURL=negative-integer.js.map
@@ -0,0 +1,3 @@
1
+ import type Newable from "@rcompat/type/Newable";
2
+ export default function isNewable(x: unknown): x is Newable;
3
+ //# sourceMappingURL=newable.d.ts.map
@@ -0,0 +1,12 @@
1
+ export default function isNewable(x) {
2
+ if (typeof x !== "function")
3
+ return false;
4
+ try {
5
+ Reflect.construct(String, [], x);
6
+ return true;
7
+ }
8
+ catch {
9
+ return false;
10
+ }
11
+ }
12
+ //# sourceMappingURL=newable.js.map
@@ -0,0 +1,2 @@
1
+ export default function isNil(x: unknown): x is null | undefined;
2
+ //# sourceMappingURL=nil.d.ts.map
@@ -0,0 +1,4 @@
1
+ export default function isNil(x) {
2
+ return x === null || x === undefined;
3
+ }
4
+ //# sourceMappingURL=nil.js.map
@@ -0,0 +1,3 @@
1
+ import type Nullish from "@rcompat/type/Nullish";
2
+ export default function isNullish(x: unknown): x is Nullish;
3
+ //# sourceMappingURL=nullish.d.ts.map
@@ -0,0 +1,4 @@
1
+ export default function isNullish(x) {
2
+ return x === null || x === undefined;
3
+ }
4
+ //# sourceMappingURL=nullish.js.map
@@ -0,0 +1,2 @@
1
+ export default function isNumeric(x: unknown): x is string;
2
+ //# sourceMappingURL=numeric.d.ts.map
@@ -0,0 +1,12 @@
1
+ const DECIMAL = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i;
2
+ export default function isNumeric(x) {
3
+ if (typeof x !== "string") {
4
+ return false;
5
+ }
6
+ const trimmed = x.trim();
7
+ if (trimmed === "") {
8
+ return false;
9
+ }
10
+ return DECIMAL.test(trimmed);
11
+ }
12
+ //# sourceMappingURL=numeric.js.map
@@ -0,0 +1,2 @@
1
+ export default function isPositiveInteger(x: unknown): x is number | bigint;
2
+ //# sourceMappingURL=positive-integer.d.ts.map
@@ -0,0 +1,5 @@
1
+ import isInteger from "#integer";
2
+ export default function isPositiveInteger(x) {
3
+ return isInteger(x) && BigInt(x) > 0n;
4
+ }
5
+ //# sourceMappingURL=positive-integer.js.map
@@ -0,0 +1,2 @@
1
+ export default function isSafeInteger(x: unknown): x is number;
2
+ //# sourceMappingURL=safe-integer.d.ts.map
@@ -0,0 +1,6 @@
1
+ export default function isSafeInteger(x) {
2
+ if (typeof x === "number")
3
+ return Number.isSafeInteger(x);
4
+ return false;
5
+ }
6
+ //# sourceMappingURL=safe-integer.js.map
@@ -0,0 +1,2 @@
1
+ export default function isTruthy(x: unknown): boolean;
2
+ //# sourceMappingURL=truthy.d.ts.map
@@ -0,0 +1,4 @@
1
+ export default function isTruthy(x) {
2
+ return !!x;
3
+ }
4
+ //# sourceMappingURL=truthy.js.map
@@ -0,0 +1,2 @@
1
+ export default function isUint(x: unknown): x is number | bigint;
2
+ //# sourceMappingURL=uint.d.ts.map
@@ -0,0 +1,5 @@
1
+ import isInteger from "#integer";
2
+ export default function isUint(x) {
3
+ return isInteger(x) && BigInt(x) > 0n;
4
+ }
5
+ //# sourceMappingURL=uint.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#blank";
2
+ //# sourceMappingURL=blank.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#blank";
2
+ //# sourceMappingURL=blank.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#boolish";
2
+ //# sourceMappingURL=boolish.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#boolish";
2
+ //# sourceMappingURL=boolish.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#defined";
2
+ //# sourceMappingURL=defined.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#defined";
2
+ //# sourceMappingURL=defined.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#empty";
2
+ //# sourceMappingURL=empty.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#empty";
2
+ //# sourceMappingURL=empty.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#falsy";
2
+ //# sourceMappingURL=falsy.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#falsy";
2
+ //# sourceMappingURL=falsy.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#finite";
2
+ //# sourceMappingURL=finite.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#finite";
2
+ //# sourceMappingURL=finite.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#integer";
2
+ //# sourceMappingURL=integer.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#integer";
2
+ //# sourceMappingURL=integer.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#nan";
2
+ //# sourceMappingURL=nan.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#nan";
2
+ //# sourceMappingURL=nan.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#newable";
2
+ //# sourceMappingURL=newable.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#newable";
2
+ //# sourceMappingURL=newable.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#nullish";
2
+ //# sourceMappingURL=nullish.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#nullish";
2
+ //# sourceMappingURL=nullish.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#numeric";
2
+ //# sourceMappingURL=numeric.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#numeric";
2
+ //# sourceMappingURL=numeric.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#safe-integer";
2
+ //# sourceMappingURL=safe-integer.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#safe-integer";
2
+ //# sourceMappingURL=safe-integer.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#truthy";
2
+ //# sourceMappingURL=truthy.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#truthy";
2
+ //# sourceMappingURL=truthy.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#uint";
2
+ //# sourceMappingURL=uint.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#uint";
2
+ //# sourceMappingURL=uint.js.map
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@rcompat/is",
3
+ "version": "0.1.0",
4
+ "description": "Standard library value qualifying",
5
+ "bugs": "https://github.com/rcompat/rcompat/issues",
6
+ "license": "MIT",
7
+ "files": [
8
+ "/lib/**/*.js",
9
+ "/lib/**/*.d.ts",
10
+ "!/**/*.spec.*"
11
+ ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/rcompat/rcompat",
15
+ "directory": "packages/is"
16
+ },
17
+ "type": "module",
18
+ "imports": {
19
+ "#*": {
20
+ "apekit": "./src/private/*.ts",
21
+ "default": "./lib/private/*.js"
22
+ }
23
+ },
24
+ "exports": {
25
+ "./*": {
26
+ "apekit": "./src/public/*.ts",
27
+ "default": "./lib/public/*.js"
28
+ }
29
+ },
30
+ "scripts": {
31
+ "build": "tsc",
32
+ "test": "npm run build && npx proby",
33
+ "clean": "rm -rf ./lib",
34
+ "knip": "knip --no-config-hints"
35
+ }
36
+ }