@spinajs/util
Advanced tools
Comparing version 2.0.224 to 2.0.225
@@ -0,1 +1,2 @@ | ||
import { Constructor } from './fp.js'; | ||
/** | ||
@@ -27,2 +28,3 @@ * Helper function to validate arguments | ||
export declare function _is_object(...checks: ((arg: object, name: string) => object)[]): (arg: object, name: string) => any; | ||
export declare function _is_instance_of(c: Constructor<unknown>, ...checks: ((arg: object, name: string) => object)[]): (arg: object, name: string) => any; | ||
export declare function _or(...checks: ((arg: any, name: string) => any)[]): (arg: any, name: string) => any; | ||
@@ -29,0 +31,0 @@ export declare function _to_upper(): (arg: unknown, _name: string) => unknown; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports._to_float = exports._to_int = exports._is_uuid = exports._is_email = exports._glob_match = exports._reg_match = exports._gt = exports._lt = exports._contains = exports._default = exports._non_empty = exports._non_nil = exports._non_NaN = exports._non_undefined = exports._non_null = exports._max = exports._min = exports._max_length = exports._min_length = exports._between = exports._trim = exports._to_lower = exports._to_array = exports._to_upper = exports._or = exports._is_object = exports._is_array = exports._is_string = exports._is_boolean = exports._contains_key = exports._is_map = exports._is_number = exports._check_arg = void 0; | ||
exports._to_float = exports._to_int = exports._is_uuid = exports._is_email = exports._glob_match = exports._reg_match = exports._gt = exports._lt = exports._contains = exports._default = exports._non_empty = exports._non_nil = exports._non_NaN = exports._non_undefined = exports._non_null = exports._max = exports._min = exports._max_length = exports._min_length = exports._between = exports._trim = exports._to_lower = exports._to_array = exports._to_upper = exports._or = exports._is_instance_of = exports._is_object = exports._is_array = exports._is_string = exports._is_boolean = exports._contains_key = exports._is_map = exports._is_number = exports._check_arg = void 0; | ||
const exceptions_1 = require("@spinajs/exceptions"); | ||
@@ -111,2 +111,11 @@ const glob_to_regexp_1 = __importDefault(require("glob-to-regexp")); | ||
exports._is_object = _is_object; | ||
function _is_instance_of(c, ...checks) { | ||
return function (arg, name) { | ||
if (typeof arg !== 'object' || arg === null || arg === undefined || Array.isArray(arg) || arg.constructor.name !== c.name) { | ||
throw new exceptions_1.InvalidArgument(`${name} is not type of ${c.name}`); | ||
} | ||
return _check_arg(...checks)(arg, name); | ||
}; | ||
} | ||
exports._is_instance_of = _is_instance_of; | ||
function _or(...checks) { | ||
@@ -113,0 +122,0 @@ return function (arg, name) { |
@@ -0,1 +1,2 @@ | ||
import { Constructor } from './fp.js'; | ||
/** | ||
@@ -27,2 +28,3 @@ * Helper function to validate arguments | ||
export declare function _is_object(...checks: ((arg: object, name: string) => object)[]): (arg: object, name: string) => any; | ||
export declare function _is_instance_of(c: Constructor<unknown>, ...checks: ((arg: object, name: string) => object)[]): (arg: object, name: string) => any; | ||
export declare function _or(...checks: ((arg: any, name: string) => any)[]): (arg: any, name: string) => any; | ||
@@ -29,0 +31,0 @@ export declare function _to_upper(): (arg: unknown, _name: string) => unknown; |
@@ -96,2 +96,10 @@ import { InvalidArgument } from '@spinajs/exceptions'; | ||
} | ||
export function _is_instance_of(c, ...checks) { | ||
return function (arg, name) { | ||
if (typeof arg !== 'object' || arg === null || arg === undefined || Array.isArray(arg) || arg.constructor.name !== c.name) { | ||
throw new InvalidArgument(`${name} is not type of ${c.name}`); | ||
} | ||
return _check_arg(...checks)(arg, name); | ||
}; | ||
} | ||
export function _or(...checks) { | ||
@@ -98,0 +106,0 @@ return function (arg, name) { |
{ | ||
"name": "@spinajs/util", | ||
"version": "2.0.224", | ||
"version": "2.0.225", | ||
"description": "utility functions shared across @spinajs framework", | ||
@@ -50,3 +50,3 @@ "main": "lib/cjs/index.js", | ||
"dependencies": { | ||
"@spinajs/exceptions": "^2.0.224", | ||
"@spinajs/exceptions": "^2.0.225", | ||
"glob-to-regexp": "^0.4.1" | ||
@@ -53,0 +53,0 @@ }, |
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
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
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
225958
1399
Updated@spinajs/exceptions@^2.0.225