New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ayonli/jsext

Package Overview
Dependencies
Maintainers
1
Versions
161
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ayonli/jsext - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

3

augment.ts

@@ -10,6 +10,3 @@ import "./string/augment";

import "./error/augment";
import jsext from "./index";
export default jsext;
declare global {

@@ -16,0 +13,0 @@ interface Constructor<T> extends Function {

@@ -12,4 +12,2 @@ "use strict";

require("./error/augment");
const index_1 = require("./index");
exports.default = index_1.default;
//# sourceMappingURL=augment.js.map

5

cjs/index.js

@@ -336,2 +336,7 @@ "use strict";

},
isSubclassOf(ctor1, ctor2) {
return typeof ctor1 === "function"
&& typeof ctor2 === "function"
&& ctor1.prototype instanceof ctor2;
},
read(source, eventMap = undefined) {

@@ -338,0 +343,0 @@ var _a;

@@ -5,4 +5,6 @@ "use strict";

Number.isFloat = _1.isFloat;
Number.isNumeric = _1.isNumeric;
Number.isBetween = _1.isBetween;
Number.random = _1.random;
Number.sequence = _1.sequence;
//# sourceMappingURL=augment.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sequence = exports.random = exports.isFloat = void 0;
/** Returns true if the given value is a float, false otherwise. */
exports.sequence = exports.random = exports.isBetween = exports.isNumeric = exports.isFloat = void 0;
/** Returns `true` if the given value is a float number, `false` otherwise. */
function isFloat(value) {

@@ -11,2 +11,33 @@ return typeof value === "number"

exports.isFloat = isFloat;
/**
* Returns `true` if the given value is a numeric value, `false` otherwise. A numeric value is a
* number, a bigint, or a string that can be converted to a number or bigint.
*/
function isNumeric(value) {
let type = typeof value;
if (type === "number" || type === "bigint") {
return true;
}
else if (type === "string") {
if (!Number.isNaN(value)) {
return true;
}
else {
try {
BigInt(value);
return true;
}
catch (_a) {
return false;
}
}
}
return false;
}
exports.isNumeric = isNumeric;
/** Return `true` if a number is between the given range (inclusive). */
function isBetween(value, [min, max]) {
return value >= min && value <= max;
}
exports.isBetween = isBetween;
/** Returns a random integer ranged from `min` to `max`. */

@@ -13,0 +44,0 @@ function random(min, max) {

@@ -10,7 +10,2 @@ import './string/augment.js';

import './error/augment.js';
import jsext from './index.js';
export { jsext as default };
//# sourceMappingURL=augment.js.map

@@ -335,2 +335,7 @@ import { isAsyncGenerator as isAsyncGenerator_1, isGenerator as isGenerator_1 } from './_external/check-iterable/index.js';

},
isSubclassOf(ctor1, ctor2) {
return typeof ctor1 === "function"
&& typeof ctor2 === "function"
&& ctor1.prototype instanceof ctor2;
},
read(source, eventMap = undefined) {

@@ -337,0 +342,0 @@ var _a;

@@ -1,6 +0,8 @@

import { isFloat, random, sequence } from './index.js';
import { isFloat, isNumeric, isBetween, random, sequence } from './index.js';
Number.isFloat = isFloat;
Number.isNumeric = isNumeric;
Number.isBetween = isBetween;
Number.random = random;
Number.sequence = sequence;
//# sourceMappingURL=augment.js.map

@@ -1,2 +0,2 @@

/** Returns true if the given value is a float, false otherwise. */
/** Returns `true` if the given value is a float number, `false` otherwise. */
function isFloat(value) {

@@ -7,2 +7,31 @@ return typeof value === "number"

}
/**
* Returns `true` if the given value is a numeric value, `false` otherwise. A numeric value is a
* number, a bigint, or a string that can be converted to a number or bigint.
*/
function isNumeric(value) {
let type = typeof value;
if (type === "number" || type === "bigint") {
return true;
}
else if (type === "string") {
if (!Number.isNaN(value)) {
return true;
}
else {
try {
BigInt(value);
return true;
}
catch (_a) {
return false;
}
}
}
return false;
}
/** Return `true` if a number is between the given range (inclusive). */
function isBetween(value, [min, max]) {
return value >= min && value <= max;
}
/** Returns a random integer ranged from `min` to `max`. */

@@ -31,3 +60,3 @@ function random(min, max) {

export { isFloat, random, sequence };
export { isBetween, isFloat, isNumeric, random, sequence };
//# sourceMappingURL=index.js.map

@@ -205,2 +205,5 @@ import { isAsyncGenerator, isGenerator } from "check-iterable";

/** Checks if a class is a subclass of another class. */
isSubclassOf<T, B>(ctor1: Constructor<T>, ctor2: Constructor<B>): boolean;
/**

@@ -548,2 +551,7 @@ * Wraps a source as an AsyncIterable object that can be used in the `for...await...` loop

},
isSubclassOf(ctor1, ctor2) {
return typeof ctor1 === "function"
&& typeof ctor2 === "function"
&& ctor1.prototype instanceof ctor2;
},
read<T>(source: any, eventMap: {

@@ -550,0 +558,0 @@ event?: string; // for EventSource custom event

@@ -1,2 +0,2 @@

import { isFloat, random, sequence } from ".";
import { isBetween, isFloat, isNumeric, random, sequence } from ".";

@@ -7,2 +7,9 @@ declare global {

isFloat(value: unknown): boolean;
/**
* Returns `true` if the given value is a numeric value, `false` otherwise. A numeric value
* is a number, a bigint, or a string that can be converted as a number or bigint.
*/
isNumeric(value: unknown): boolean;
/** Return `true` if a number is between the given range (inclusive). */
isBetween(value: number, [min, max]: [number, number]): boolean;
/** Returns a random integer ranged from `min` to `max` (inclusive). */

@@ -16,3 +23,5 @@ random(min: number, max: number): number;

Number.isFloat = isFloat;
Number.isNumeric = isNumeric;
Number.isBetween = isBetween;
Number.random = random;
Number.sequence = sequence;

@@ -1,2 +0,2 @@

/** Returns true if the given value is a float, false otherwise. */
/** Returns `true` if the given value is a float number, `false` otherwise. */
export function isFloat(value: unknown): boolean {

@@ -8,2 +8,32 @@ return typeof value === "number"

/**
* Returns `true` if the given value is a numeric value, `false` otherwise. A numeric value is a
* number, a bigint, or a string that can be converted to a number or bigint.
*/
export function isNumeric(value: unknown): boolean {
let type = typeof value;
if (type === "number" || type === "bigint") {
return true;
} else if (type === "string") {
if (!Number.isNaN(value)) {
return true;
} else {
try {
BigInt(value as string);
return true;
} catch {
return false;
}
}
}
return false;
}
/** Return `true` if a number is between the given range (inclusive). */
export function isBetween(value: number, [min, max]: [number, number]): boolean {
return value >= min && value <= max;
}
/** Returns a random integer ranged from `min` to `max`. */

@@ -10,0 +40,0 @@ export function random(min: number, max: number): number {

{
"name": "@ayonli/jsext",
"version": "0.4.1",
"version": "0.4.2",
"description": "Additional functions for JavaScript programming in practice.",

@@ -101,3 +101,2 @@ "exports": {

"test": "mocha",
"postpublish": "ls *.js|grep -v config.js|grep -v example.js|xargs rm; ls *.js.map|xargs rm; ls */*.js|grep -v bundle|grep -v esm|xargs rm; ls */*.js.map|grep -v bundle|grep -v esm|xargs rm",
"build": "tsc && rollup -c rollup.config.mjs && rollup -c rollup-worker.config.mjs && webpack",

@@ -177,5 +176,6 @@ "prepublishOnly": "npm run build"

"spec": [
"**/*.test.ts"
"*.test.ts",
"*/**.test.ts"
]
}
}

@@ -39,2 +39,4 @@ # JsExt

- `isSubclassOf<T, B>(ctor1: Constructor<T>, ctor2: Constructor<B>): boolean`
- `read<I extends AsyncIterable<any>>(iterable: I): I`

@@ -97,2 +99,4 @@ - `read(es: EventSource, options?: { event?: string; }): AsyncIterable<string>`

- `isFloat(value: unknown): boolean`
- `isNumeric(value: unknown): boolean`
- `isBetween(value: number, [min, max]: [number, number]): boolean`
- `random(min: number, max: number): number`

@@ -312,3 +316,3 @@ - `sequence(min: number, max: number, step?: number, loop?: boolean): Generator<number, void, unknown>`

// or sub-packages
import { isFloat } from "https://deno.land/x/ayonli_jsext/esm/number/index.js";
import { isFloat, isNumeric } from "https://deno.land/x/ayonli_jsext/esm/number/index.js";
import "https://deno.land/x/ayonli_jsext/esm/number/augment.js";

@@ -325,5 +329,5 @@ </script>

<script>
const { default: jsext } = window["@ayonli/jsext"];
const jsext = window["@ayonli/jsext"];
// this will also include the augmentations
<script>
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc