@jblib/is 0.0.1 → 0.0.3

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Joseph Beck
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,9 +1,16 @@
1
1
  //#region src/is-number.d.ts
2
2
  /**
3
- * Checks if a value is a number.
3
+ * isNumber checks if the provided value is a number.
4
4
  *
5
- * @param v value to check
6
- * @returns boolean indicating if the value is a number
5
+ * @param v value to check.
6
+ * @returns {v is number} returns true if v is a number or otherwise false.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * isNumber(123) // true
11
+ * isNumber('hello') // false
12
+ * isNumber({}) // false
13
+ * ```
7
14
  */
8
15
  declare const isNumber: (v: unknown) => v is number;
9
16
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"is-number.d.ts","names":[],"sources":["../src/is-number.ts"],"mappings":";;;;;;;cAMM,QAAA,GAAY,CAAA,cAAa,CAAA"}
1
+ {"version":3,"file":"is-number.d.ts","names":[],"sources":["../src/is-number.ts"],"mappings":";;;;;;;;;;;;;;cAaM,QAAA,GAAY,CAAA,cAAa,CAAA"}
package/dist/is-number.js CHANGED
@@ -1,9 +1,16 @@
1
1
  //#region src/is-number.ts
2
2
  /**
3
- * Checks if a value is a number.
3
+ * isNumber checks if the provided value is a number.
4
4
  *
5
- * @param v value to check
6
- * @returns boolean indicating if the value is a number
5
+ * @param v value to check.
6
+ * @returns {v is number} returns true if v is a number or otherwise false.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * isNumber(123) // true
11
+ * isNumber('hello') // false
12
+ * isNumber({}) // false
13
+ * ```
7
14
  */
8
15
  const isNumber = (v) => typeof v === "number";
9
16
 
@@ -1 +1 @@
1
- {"version":3,"file":"is-number.js","names":[],"sources":["../src/is-number.ts"],"sourcesContent":["/**\n * Checks if a value is a number.\n *\n * @param v value to check\n * @returns boolean indicating if the value is a number\n */\nconst isNumber = (v: unknown): v is number => typeof v === 'number'\n\nexport { isNumber }\n"],"mappings":";;;;;;;AAMA,MAAM,YAAY,MAA4B,OAAO,MAAM"}
1
+ {"version":3,"file":"is-number.js","names":[],"sources":["../src/is-number.ts"],"sourcesContent":["/**\n * isNumber checks if the provided value is a number.\n *\n * @param v value to check.\n * @returns {v is number} returns true if v is a number or otherwise false.\n *\n * @example\n * ```ts\n * isNumber(123) // true\n * isNumber('hello') // false\n * isNumber({}) // false\n * ```\n */\nconst isNumber = (v: unknown): v is number => typeof v === 'number'\n\nexport { isNumber }\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAM,YAAY,MAA4B,OAAO,MAAM"}
@@ -1,9 +1,16 @@
1
1
  //#region src/is-string.d.ts
2
2
  /**
3
- * Checks if a value is a string.
3
+ * isString checks if the provided value is a string.
4
4
  *
5
- * @param v value to check
6
- * @returns boolean indicating if the value is a string
5
+ * @param v value to check.
6
+ * @returns {v is string} returns true if v is a string or otherwise false.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * isString('hello') // true
11
+ * isString(123) // false
12
+ * isString({}) // false
13
+ * ```
7
14
  */
8
15
  declare const isString: (v: unknown) => v is string;
9
16
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"is-string.d.ts","names":[],"sources":["../src/is-string.ts"],"mappings":";;;;;;;cAMM,QAAA,GAAY,CAAA,cAAa,CAAA"}
1
+ {"version":3,"file":"is-string.d.ts","names":[],"sources":["../src/is-string.ts"],"mappings":";;;;;;;;;;;;;;cAaM,QAAA,GAAY,CAAA,cAAa,CAAA"}
package/dist/is-string.js CHANGED
@@ -1,9 +1,16 @@
1
1
  //#region src/is-string.ts
2
2
  /**
3
- * Checks if a value is a string.
3
+ * isString checks if the provided value is a string.
4
4
  *
5
- * @param v value to check
6
- * @returns boolean indicating if the value is a string
5
+ * @param v value to check.
6
+ * @returns {v is string} returns true if v is a string or otherwise false.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * isString('hello') // true
11
+ * isString(123) // false
12
+ * isString({}) // false
13
+ * ```
7
14
  */
8
15
  const isString = (v) => typeof v === "string";
9
16
 
@@ -1 +1 @@
1
- {"version":3,"file":"is-string.js","names":[],"sources":["../src/is-string.ts"],"sourcesContent":["/**\n * Checks if a value is a string.\n *\n * @param v value to check\n * @returns boolean indicating if the value is a string\n */\nconst isString = (v: unknown): v is string => typeof v === 'string'\n\nexport { isString }\n"],"mappings":";;;;;;;AAMA,MAAM,YAAY,MAA4B,OAAO,MAAM"}
1
+ {"version":3,"file":"is-string.js","names":[],"sources":["../src/is-string.ts"],"sourcesContent":["/**\n * isString checks if the provided value is a string.\n *\n * @param v value to check.\n * @returns {v is string} returns true if v is a string or otherwise false.\n *\n * @example\n * ```ts\n * isString('hello') // true\n * isString(123) // false\n * isString({}) // false\n * ```\n */\nconst isString = (v: unknown): v is string => typeof v === 'string'\n\nexport { isString }\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAM,YAAY,MAA4B,OAAO,MAAM"}
package/package.json CHANGED
@@ -1,20 +1,14 @@
1
1
  {
2
2
  "name": "@jblib/is",
3
- "version": "0.0.1",
4
- "description": "is",
3
+ "version": "0.0.3",
4
+ "description": "is, condition checks",
5
5
  "type": "module",
6
- "scripts": {
7
- "build": "tsdown",
8
- "test": "vitest",
9
- "lint": "eslint .",
10
- "lint:fix": "eslint . --fix"
11
- },
12
6
  "devDependencies": {
13
- "vitest": "catalog:",
14
- "typescript": "catalog:",
15
- "@jblib/eslint": "workspace:*",
16
- "prettier": "catalog:",
17
- "tsdown": "catalog:"
7
+ "prettier": "^3.8.3",
8
+ "tsdown": "^0.21.10",
9
+ "typescript": "^6.0.3",
10
+ "vitest": "^4.1.5",
11
+ "@jblib/eslint": "0.0.4"
18
12
  },
19
13
  "keywords": [
20
14
  "is"
@@ -22,21 +16,25 @@
22
16
  "author": {
23
17
  "name": "Joseph Beck"
24
18
  },
19
+ "files": [
20
+ "dist",
21
+ "src"
22
+ ],
23
+ "types": "./dist/index.d.ts",
25
24
  "repository": {
26
25
  "type": "git",
27
26
  "url": "git+https://github.com/joseph-beck/jblib.git",
28
27
  "directory": "packages/is"
29
28
  },
30
29
  "license": "MIT",
31
- "packageManager": "pnpm@10.33.0",
32
30
  "exports": {
33
- ".": "./src/index.ts",
31
+ ".": "./dist/index.js",
34
32
  "./package.json": "./package.json"
35
33
  },
36
- "publishConfig": {
37
- "exports": {
38
- ".": "./dist/index.js",
39
- "./package.json": "./package.json"
40
- }
34
+ "scripts": {
35
+ "build": "tsdown",
36
+ "test": "vitest",
37
+ "lint": "eslint .",
38
+ "lint:fix": "eslint . --fix"
41
39
  }
42
- }
40
+ }
@@ -0,0 +1,18 @@
1
+ import { describe, expect, it } from 'vitest'
2
+
3
+ import { isArray } from './is-array.js'
4
+
5
+ describe('is array', () => {
6
+ it('should return true for arrays', () => {
7
+ expect(isArray([])).toBe(true)
8
+ expect(isArray([1, 2, 3])).toBe(true)
9
+ })
10
+
11
+ it('should return false for non-arrays', () => {
12
+ expect(isArray('hello')).toBe(false)
13
+ expect(isArray({})).toBe(false)
14
+ expect(isArray(123)).toBe(false)
15
+ expect(isArray(null)).toBe(false)
16
+ expect(isArray(undefined)).toBe(false)
17
+ })
18
+ })
@@ -0,0 +1,19 @@
1
+ /**
2
+ * isArray checks if the provided value is an array.
3
+ *
4
+ * @param v value to check.
5
+ * @returns {v is unknown[]} returns true if the value is an array or otherwise false.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * isArray([]) // true
10
+ * isArray([1, 2, 3]) // true
11
+ * isArray('hello') // false
12
+ * isArray({}) // false
13
+ * isArray(123) // false
14
+ * isArray(undefined) // false
15
+ * ```
16
+ */
17
+ const isArray = (v: unknown): v is unknown[] => Array.isArray(v)
18
+
19
+ export { isArray }
@@ -0,0 +1,35 @@
1
+ import { describe, expect, it } from 'vitest'
2
+
3
+ import { isFunction } from './is-function.js'
4
+
5
+ describe('is function', () => {
6
+ it('should return true for functions', () => {
7
+ expect(
8
+ isFunction(() => {
9
+ void 0
10
+ }),
11
+ ).toBe(true)
12
+
13
+ expect(
14
+ isFunction(function () {
15
+ void 0
16
+ }),
17
+ ).toBe(true)
18
+
19
+ expect(
20
+ // eslint-disable-next-line @typescript-eslint/require-await
21
+ isFunction(async function () {
22
+ void 0
23
+ }),
24
+ ).toBe(true)
25
+ })
26
+
27
+ it('should return false for non-functions', () => {
28
+ expect(isFunction('hello')).toBe(false)
29
+ expect(isFunction({})).toBe(false)
30
+ expect(isFunction(123)).toBe(false)
31
+ expect(isFunction(null)).toBe(false)
32
+ expect(isFunction(undefined)).toBe(false)
33
+ expect(isFunction([])).toBe(false)
34
+ })
35
+ })
@@ -0,0 +1,18 @@
1
+ /**
2
+ * isFunction checks if the provided value is a function.
3
+ *
4
+ * @param v value to check.
5
+ * @returns {v is (...args: unknown[]) => unknown} returns true if v is a function or otherwise false.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * isFunction(() => {}) // true
10
+ * isFunction(function() {}) // true
11
+ * isFunction(async function() {}) // true
12
+ * isFunction('hello') // false
13
+ * isFunction({}) // false
14
+ * ```
15
+ */
16
+ const isFunction = (v: unknown): v is (...args: unknown[]) => unknown => typeof v === 'function'
17
+
18
+ export { isFunction }
@@ -0,0 +1,21 @@
1
+ import { describe, expect, it } from 'vitest'
2
+
3
+ import { isNonEmptyArray } from './is-non-empty-array.js'
4
+
5
+ describe('is non empty array', () => {
6
+ it('should return true for non-empty arrays', () => {
7
+ expect(isNonEmptyArray([1, 2, 3])).toBe(true)
8
+ })
9
+
10
+ it('should return false for empty arrays', () => {
11
+ expect(isNonEmptyArray([])).toBe(false)
12
+ })
13
+
14
+ it('should return false for non-arrays', () => {
15
+ expect(isNonEmptyArray('hello')).toBe(false)
16
+ expect(isNonEmptyArray({})).toBe(false)
17
+ expect(isNonEmptyArray(123)).toBe(false)
18
+ expect(isNonEmptyArray(null)).toBe(false)
19
+ expect(isNonEmptyArray(undefined)).toBe(false)
20
+ })
21
+ })
@@ -0,0 +1,17 @@
1
+ /**
2
+ * isNonEmptyArray checks if the provided value is an array and contains at least one element.
3
+ *
4
+ * @param v value to check.
5
+ * @returns {v is unknown[]} returns true if v is a non-empty array or otherwise false.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * isNonEmptyArray([1, 2, 3]) // true
10
+ * isNonEmptyArray([]) // false
11
+ * isNonEmptyArray('hello') // false
12
+ * isNonEmptyArray({}) // false
13
+ * ```
14
+ */
15
+ const isNonEmptyArray = (v: unknown): v is unknown[] => Array.isArray(v) && v.length > 0
16
+
17
+ export { isNonEmptyArray }
package/src/is-number.ts CHANGED
@@ -1,8 +1,15 @@
1
1
  /**
2
- * Checks if a value is a number.
2
+ * isNumber checks if the provided value is a number.
3
3
  *
4
- * @param v value to check
5
- * @returns boolean indicating if the value is a number
4
+ * @param v value to check.
5
+ * @returns {v is number} returns true if v is a number or otherwise false.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * isNumber(123) // true
10
+ * isNumber('hello') // false
11
+ * isNumber({}) // false
12
+ * ```
6
13
  */
7
14
  const isNumber = (v: unknown): v is number => typeof v === 'number'
8
15
 
package/src/is-string.ts CHANGED
@@ -1,8 +1,15 @@
1
1
  /**
2
- * Checks if a value is a string.
2
+ * isString checks if the provided value is a string.
3
3
  *
4
- * @param v value to check
5
- * @returns boolean indicating if the value is a string
4
+ * @param v value to check.
5
+ * @returns {v is string} returns true if v is a string or otherwise false.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * isString('hello') // true
10
+ * isString(123) // false
11
+ * isString({}) // false
12
+ * ```
6
13
  */
7
14
  const isString = (v: unknown): v is string => typeof v === 'string'
8
15
 
package/eslint.config.ts DELETED
@@ -1,6 +0,0 @@
1
- import { jblibConfig } from '@jblib/eslint'
2
- import { type Linter } from 'eslint'
3
-
4
- const config: Linter.Config[] = [...jblibConfig]
5
-
6
- export default config
package/tsconfig.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "composite": true,
5
- "noEmit": false
6
- },
7
- "include": ["src", "*.config.ts"]
8
- }
package/tsdown.config.ts DELETED
@@ -1,23 +0,0 @@
1
- import { defineConfig } from 'tsdown'
2
-
3
- export default defineConfig({
4
- entry: ['./src/index.ts'],
5
- format: ['esm'],
6
- platform: 'node',
7
- unbundle: true,
8
- dts: true,
9
- sourcemap: true,
10
- clean: true,
11
- minify: false,
12
- fixedExtension: false,
13
- exports: {
14
- devExports: true,
15
- },
16
- publint: {
17
- strict: true,
18
- },
19
- attw: {
20
- profile: 'esm-only',
21
- level: 'error',
22
- },
23
- })
package/vitest.config.ts DELETED
@@ -1,11 +0,0 @@
1
- import { defineConfig } from 'vitest/config'
2
-
3
- export default defineConfig({
4
- test: {
5
- exclude: ['src/**/*.gen.ts'],
6
- include: ['src/**/*.spec.ts'],
7
- },
8
- resolve: {
9
- tsconfigPaths: true,
10
- },
11
- })