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

isntnt

Package Overview
Dependencies
Maintainers
8
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isntnt - npm Package Compare versions

Comparing version 1.5.1 to 1.5.2

2

dist/esm/lib/generics/either.d.ts
import { Primitive, Predicate } from '../types';
export declare const either: <T extends Primitive[]>(...options: T) => Predicate<T[number]>;
export declare const either: <T extends readonly Primitive[]>(...options: T) => Predicate<T[number]>;

@@ -1,4 +0,9 @@

import { or } from './or';
import { literal } from './literal';
export const either = (...options) => or(...options.map(literal));
export const either = (...options) => (value) => {
let length = options.length;
let isValid = length === 0;
while (!isValid && length) {
isValid = value === options[--length];
}
return isValid;
};
//# sourceMappingURL=either.js.map

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

import { Predicate } from '../types';
export declare const maybe: <T>(predicate: Predicate<T>) => Predicate<import("../types").None | T>;
import { Maybe, Predicate } from '../types';
export declare const maybe: <T>(predicate: Predicate<T>) => Predicate<Maybe<T>>;

@@ -1,4 +0,3 @@

import { or } from './or';
import { isNone } from '../predicates/isNone';
export const maybe = (predicate) => or(predicate, isNone);
export const maybe = (predicate) => (value) => isNone(value) || predicate(value);
//# sourceMappingURL=maybe.js.map

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

export declare const noneable: <T>(predicate: import("../types").Predicate<T>) => import("../types").Predicate<import("../types").None | T>;
export declare const noneable: <T>(predicate: import("../types").Predicate<T>) => import("../types").Predicate<import("../types").Maybe<T>>;

@@ -1,4 +0,3 @@

import { or } from './or';
import { isNull } from '../predicates/isNull';
export const nullable = (predicate) => or(predicate, isNull);
export const nullable = (predicate) => (value) => isNull(value) || predicate(value);
//# sourceMappingURL=nullable.js.map

@@ -1,4 +0,3 @@

import { or } from './or';
import { isUndefined } from '../predicates/isUndefined';
export const optional = (predicate) => or(predicate, isUndefined);
export const optional = (predicate) => (value) => isUndefined(value) || predicate(value);
//# sourceMappingURL=optional.js.map

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

import { or } from '../generics/or';
import { isNumber } from './isNumber';

@@ -7,3 +6,3 @@ import { isNumericString } from './isNumericString';

*/
export const isNumeric = or(isNumber, isNumericString);
export const isNumeric = (value) => isNumber(value) || isNumericString(value);
//# sourceMappingURL=isNumeric.js.map

@@ -1,7 +0,6 @@

import { and } from '../generics/and';
import { isSome } from './isSome';
import { isNull } from './isNull';
/**
* Checks if a value is an object.
*/
export const isObject = and(isSome, (value) => typeof value === 'object');
export const isObject = (value) => !isNull(value) && typeof value === 'object';
//# sourceMappingURL=isObject.js.map

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

import { and } from '../generics/and';
import { at } from '../generics/at';

@@ -8,3 +7,3 @@ import { isObject } from './isObject';

*/
export const isPlainObject = and(isObject, (value) => hasObjectConstructor(Object.getPrototypeOf(value)) && String(value) === '[object Object]');
export const isPlainObject = (value) => isObject(value) && hasObjectConstructor(value) && String(value) === '[object Object]';
//# sourceMappingURL=isPlainObject.js.map
import { Primitive, Predicate } from '../types';
export declare const either: <T extends Primitive[]>(...options: T) => Predicate<T[number]>;
export declare const either: <T extends readonly Primitive[]>(...options: T) => Predicate<T[number]>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.either = void 0;
const or_1 = require("./or");
const literal_1 = require("./literal");
const either = (...options) => (0, or_1.or)(...options.map(literal_1.literal));
const either = (...options) => (value) => {
let length = options.length;
let isValid = length === 0;
while (!isValid && length) {
isValid = value === options[--length];
}
return isValid;
};
exports.either = either;
//# sourceMappingURL=either.js.map

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

import { Predicate } from '../types';
export declare const maybe: <T>(predicate: Predicate<T>) => Predicate<import("../types").None | T>;
import { Maybe, Predicate } from '../types';
export declare const maybe: <T>(predicate: Predicate<T>) => Predicate<Maybe<T>>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.maybe = void 0;
const or_1 = require("./or");
const isNone_1 = require("../predicates/isNone");
const maybe = (predicate) => (0, or_1.or)(predicate, isNone_1.isNone);
const maybe = (predicate) => (value) => (0, isNone_1.isNone)(value) || predicate(value);
exports.maybe = maybe;
//# sourceMappingURL=maybe.js.map

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

export declare const noneable: <T>(predicate: import("../types").Predicate<T>) => import("../types").Predicate<import("../types").None | T>;
export declare const noneable: <T>(predicate: import("../types").Predicate<T>) => import("../types").Predicate<import("../types").Maybe<T>>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.nullable = void 0;
const or_1 = require("./or");
const isNull_1 = require("../predicates/isNull");
const nullable = (predicate) => (0, or_1.or)(predicate, isNull_1.isNull);
const nullable = (predicate) => (value) => (0, isNull_1.isNull)(value) || predicate(value);
exports.nullable = nullable;
//# sourceMappingURL=nullable.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.optional = void 0;
const or_1 = require("./or");
const isUndefined_1 = require("../predicates/isUndefined");
const optional = (predicate) => (0, or_1.or)(predicate, isUndefined_1.isUndefined);
const optional = (predicate) => (value) => (0, isUndefined_1.isUndefined)(value) || predicate(value);
exports.optional = optional;
//# sourceMappingURL=optional.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isNumeric = void 0;
const or_1 = require("../generics/or");
const isNumber_1 = require("./isNumber");

@@ -10,3 +9,4 @@ const isNumericString_1 = require("./isNumericString");

*/
exports.isNumeric = (0, or_1.or)(isNumber_1.isNumber, isNumericString_1.isNumericString);
const isNumeric = (value) => (0, isNumber_1.isNumber)(value) || (0, isNumericString_1.isNumericString)(value);
exports.isNumeric = isNumeric;
//# sourceMappingURL=isNumeric.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isObject = void 0;
const and_1 = require("../generics/and");
const isSome_1 = require("./isSome");
const isNull_1 = require("./isNull");
/**
* Checks if a value is an object.
*/
exports.isObject = (0, and_1.and)(isSome_1.isSome, (value) => typeof value === 'object');
const isObject = (value) => !(0, isNull_1.isNull)(value) && typeof value === 'object';
exports.isObject = isObject;
//# sourceMappingURL=isObject.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isPlainObject = exports.hasObjectConstructor = void 0;
const and_1 = require("../generics/and");
const at_1 = require("../generics/at");

@@ -11,3 +10,4 @@ const isObject_1 = require("./isObject");

*/
exports.isPlainObject = (0, and_1.and)(isObject_1.isObject, (value) => (0, exports.hasObjectConstructor)(Object.getPrototypeOf(value)) && String(value) === '[object Object]');
const isPlainObject = (value) => (0, isObject_1.isObject)(value) && (0, exports.hasObjectConstructor)(value) && String(value) === '[object Object]';
exports.isPlainObject = isPlainObject;
//# sourceMappingURL=isPlainObject.js.map
{
"name": "isntnt",
"version": "1.5.1",
"version": "1.5.2",
"description": "A collection of composable JavaScript runtime type predicates with TypeScript type guard declarations",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -9,4 +9,4 @@ import { either } from '../generics'

test('returns a function', () => {
const isEitherAbcOrXyz = either('abc', 'xyz')
expect(isEitherAbcOrXyz).toBeInstanceOf(Function)
const isEitherOf2 = either('abc', 'xyz')
expect(isEitherOf2).toBeInstanceOf(Function)
})

@@ -23,5 +23,9 @@

test('returns true if its inputs equals any of its provided values', () => {
const isEitherAbcOrXyz = either('abc', 'xyz')
expect(isEitherAbcOrXyz('abc')).toBe(true)
expect(isEitherAbcOrXyz('xyz')).toBe(true)
const isEitherOf2 = either('abc', 'xyz')
expect(isEitherOf2('abc')).toBe(true)
expect(isEitherOf2('xyz')).toBe(true)
const isEitherOf3 = either('abc', 'mno', 'xyz')
expect(isEitherOf3('abc')).toBe(true)
expect(isEitherOf3('mno')).toBe(true)
expect(isEitherOf3('xyz')).toBe(true)
})

@@ -28,0 +32,0 @@

import { Primitive, Predicate } from '../types'
import { or } from './or'
import { literal } from './literal'
export const either = <T extends Array<Primitive>>(...options: T) =>
or(...options.map(literal)) as Predicate<T[number]>
export const either =
<T extends ReadonlyArray<Primitive>>(...options: T): Predicate<T[number]> =>
(value: unknown): value is T[number] => {
let length = options.length
let isValid = length === 0
while (!isValid && length) {
isValid = value === options[--length]
}
return isValid
}

@@ -1,5 +0,7 @@

import { Predicate } from '../types'
import { or } from './or'
import { Maybe, Predicate } from '../types'
import { isNone } from '../predicates/isNone'
export const maybe = <T>(predicate: Predicate<T>) => or(predicate, isNone)
export const maybe =
<T>(predicate: Predicate<T>): Predicate<Maybe<T>> =>
(value: unknown): value is Maybe<T> =>
isNone(value) || predicate(value)

@@ -1,5 +0,7 @@

import { Predicate } from '../types'
import { or } from './or'
import { Nullable, Predicate } from '../types'
import { isNull } from '../predicates/isNull'
export const nullable = <T>(predicate: Predicate<T>): Predicate<T | null> => or(predicate, isNull)
export const nullable =
<T>(predicate: Predicate<T>): Predicate<T | null> =>
(value: unknown): value is Nullable<T> =>
isNull(value) || predicate(value)
import { Predicate } from '../types'
import { or } from './or'
import { isUndefined } from '../predicates/isUndefined'
export const optional = <T>(predicate: Predicate<T>) => or(predicate, isUndefined)
export const optional =
<T>(predicate: Predicate<T>): Predicate<T | undefined> =>
(value: unknown): value is T | undefined =>
isUndefined(value) || predicate(value)

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

import { or } from '../generics/or'
import { Predicate } from '../types'

@@ -11,2 +10,3 @@ import { isNumber } from './isNumber'

*/
export const isNumeric: Predicate<Numeric> = or(isNumber, isNumericString)
export const isNumeric: Predicate<Numeric> = (value: unknown): value is Numeric =>
isNumber(value) || isNumericString(value)
import { Predicate } from '../types'
import { and } from '../generics/and'
import { isSome } from './isSome'
import { isNull } from './isNull'

@@ -8,5 +7,3 @@ /**

*/
export const isObject: Predicate<object> = and(
isSome,
(value: unknown): value is object => typeof value === 'object',
)
export const isObject: Predicate<object> = (value: unknown): value is object =>
!isNull(value) && typeof value === 'object'
import { PlainObject, Predicate } from '../types'
import { and } from '../generics/and'
import { at } from '../generics/at'

@@ -14,6 +13,3 @@ import { isObject } from './isObject'

*/
export const isPlainObject: Predicate<PlainObject> = and(
isObject,
(value: unknown): value is PlainObject =>
hasObjectConstructor(Object.getPrototypeOf(value)) && String(value) === '[object Object]',
)
export const isPlainObject: Predicate<PlainObject> = (value: unknown): value is PlainObject =>
isObject(value) && hasObjectConstructor(value) && String(value) === '[object Object]'

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

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