@miyauci/isx
Advanced tools
Comparing version 1.1.1 to 1.2.0-beta.1
// Copyright 2023-latest Tomoki Miyauchi. All rights reserved. MIT license. | ||
// This module is browser compatible. | ||
export function isEmpty(input) { | ||
return ![...input].length; | ||
for (const _ of input) | ||
return false; | ||
return true; | ||
} |
// Copyright 2023-latest Tomoki Miyauchi. All rights reserved. MIT license. | ||
// This module is browser compatible. | ||
export function isNotEmpty(input) { | ||
return !![...input].length; | ||
for (const _ of input) | ||
return true; | ||
return false; | ||
} |
// Copyright 2023-latest Tomoki Miyauchi. All rights reserved. MIT license. | ||
// This module is browser compatible. | ||
export function isSingle(input) { | ||
return [...input].length === 1; | ||
const iterator = input[Symbol.iterator](); | ||
return !iterator.next().done && (iterator.next().done ?? false); | ||
} |
{ | ||
"name": "@miyauci/isx", | ||
"version": "1.1.1", | ||
"version": "1.2.0-beta.1", | ||
"description": "Collection of validation functions for JavaScript data", | ||
@@ -37,2 +37,5 @@ "license": "MIT", | ||
], | ||
"is_array": [ | ||
"types/is_array.d.ts" | ||
], | ||
"is_async_iterable": [ | ||
@@ -127,2 +130,7 @@ "types/is_async_iterable.d.ts" | ||
}, | ||
"./is_array": { | ||
"import": "./esm/is_array.js", | ||
"require": "./script/is_array.js", | ||
"types": "./types/is_array.d.ts" | ||
}, | ||
"./is_async_iterable": { | ||
@@ -129,0 +137,0 @@ "import": "./esm/is_async_iterable.js", |
@@ -195,2 +195,22 @@ # isx | ||
## isArray | ||
[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/isx/is_array.ts&badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fisx%2Fis_array.ts) | ||
Whether the input is array or not. | ||
_**Use only if input contains `ReadOnlyArray`**_. It improves type inference. | ||
Otherwise, use `Array.isArray`. | ||
This exists only because of TypeScript bug | ||
[#17002](https://github.com/microsoft/TypeScript/issues/17002). When this is | ||
fixed, this function will no longer be provided. | ||
```ts | ||
import { isArray } from "https://deno.land/x/isx@$VERSION/is_array.ts"; | ||
import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; | ||
assertEquals(isArray([]), true); | ||
assertEquals(isArray({}), false); | ||
``` | ||
## isPromise | ||
@@ -197,0 +217,0 @@ |
@@ -7,4 +7,6 @@ "use strict"; | ||
function isEmpty(input) { | ||
return ![...input].length; | ||
for (const _ of input) | ||
return false; | ||
return true; | ||
} | ||
exports.isEmpty = isEmpty; |
@@ -7,4 +7,6 @@ "use strict"; | ||
function isNotEmpty(input) { | ||
return !![...input].length; | ||
for (const _ of input) | ||
return true; | ||
return false; | ||
} | ||
exports.isNotEmpty = isNotEmpty; |
@@ -7,4 +7,5 @@ "use strict"; | ||
function isSingle(input) { | ||
return [...input].length === 1; | ||
const iterator = input[Symbol.iterator](); | ||
return !iterator.next().done && (iterator.next().done ?? false); | ||
} | ||
exports.isSingle = isSingle; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76009
92
1381
500
1