@xylabs/typeof
Advanced tools
Comparing version 2.13.20 to 2.13.21
@@ -0,39 +1,57 @@ | ||
var __defProp = Object.defineProperty; | ||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); | ||
// src/typeOf.ts | ||
var typeOf = (item) => { | ||
var typeOf = /* @__PURE__ */ __name((item) => { | ||
return Array.isArray(item) ? "array" : typeof item; | ||
}; | ||
}, "typeOf"); | ||
// src/ifDefined.ts | ||
var ifDefined = (value, func) => { | ||
var ifDefined = /* @__PURE__ */ __name((value, func) => { | ||
switch (typeOf(value)) { | ||
case "undefined": | ||
case "null": | ||
case "null": { | ||
break; | ||
default: | ||
} | ||
default: { | ||
func(value); | ||
return value; | ||
} | ||
} | ||
}; | ||
}, "ifDefined"); | ||
// src/ifTypeOf.ts | ||
var ifTypeOf = (typeName, value, trueFunc, isFunc) => { | ||
var ifTypeOf = /* @__PURE__ */ __name((typeName, value, trueFunc, isFunc) => { | ||
switch (typeOf(value)) { | ||
case typeName: | ||
case typeName: { | ||
return !isFunc || isFunc(value) ? trueFunc(value) : void 0; | ||
} | ||
} | ||
}; | ||
}, "ifTypeOf"); | ||
// src/validateType.ts | ||
var validateType = (typeName, value, optional = false) => { | ||
var validateType = /* @__PURE__ */ __name((typeName, value, optional = false) => { | ||
switch (typeOf(value)) { | ||
case typeName: | ||
return [value, []]; | ||
case typeName: { | ||
return [ | ||
value, | ||
[] | ||
]; | ||
} | ||
default: { | ||
if (optional && typeOf(value) === "undefined") { | ||
return [value, []]; | ||
return [ | ||
value, | ||
[] | ||
]; | ||
} | ||
return [void 0, [Error(`value type is not '${typeName}:${typeof value}'`)]]; | ||
return [ | ||
void 0, | ||
[ | ||
Error(`value type is not '${typeName}:${typeof value}'`) | ||
] | ||
]; | ||
} | ||
} | ||
}; | ||
}, "validateType"); | ||
export { | ||
@@ -40,0 +58,0 @@ ifDefined, |
@@ -0,39 +1,57 @@ | ||
var __defProp = Object.defineProperty; | ||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); | ||
// src/typeOf.ts | ||
var typeOf = (item) => { | ||
var typeOf = /* @__PURE__ */ __name((item) => { | ||
return Array.isArray(item) ? "array" : typeof item; | ||
}; | ||
}, "typeOf"); | ||
// src/ifDefined.ts | ||
var ifDefined = (value, func) => { | ||
var ifDefined = /* @__PURE__ */ __name((value, func) => { | ||
switch (typeOf(value)) { | ||
case "undefined": | ||
case "null": | ||
case "null": { | ||
break; | ||
default: | ||
} | ||
default: { | ||
func(value); | ||
return value; | ||
} | ||
} | ||
}; | ||
}, "ifDefined"); | ||
// src/ifTypeOf.ts | ||
var ifTypeOf = (typeName, value, trueFunc, isFunc) => { | ||
var ifTypeOf = /* @__PURE__ */ __name((typeName, value, trueFunc, isFunc) => { | ||
switch (typeOf(value)) { | ||
case typeName: | ||
case typeName: { | ||
return !isFunc || isFunc(value) ? trueFunc(value) : void 0; | ||
} | ||
} | ||
}; | ||
}, "ifTypeOf"); | ||
// src/validateType.ts | ||
var validateType = (typeName, value, optional = false) => { | ||
var validateType = /* @__PURE__ */ __name((typeName, value, optional = false) => { | ||
switch (typeOf(value)) { | ||
case typeName: | ||
return [value, []]; | ||
case typeName: { | ||
return [ | ||
value, | ||
[] | ||
]; | ||
} | ||
default: { | ||
if (optional && typeOf(value) === "undefined") { | ||
return [value, []]; | ||
return [ | ||
value, | ||
[] | ||
]; | ||
} | ||
return [void 0, [Error(`value type is not '${typeName}:${typeof value}'`)]]; | ||
return [ | ||
void 0, | ||
[ | ||
Error(`value type is not '${typeName}:${typeof value}'`) | ||
] | ||
]; | ||
} | ||
} | ||
}; | ||
}, "validateType"); | ||
export { | ||
@@ -40,0 +58,0 @@ ifDefined, |
@@ -14,6 +14,9 @@ { | ||
"devDependencies": { | ||
"@xylabs/ts-scripts-yarn3": "^3.2.10", | ||
"@xylabs/tsconfig": "^3.2.10", | ||
"typescript": "^5.3.2" | ||
"@xylabs/ts-scripts-yarn3": "^3.2.25", | ||
"@xylabs/tsconfig": "^3.2.25", | ||
"typescript": "^5.3.3" | ||
}, | ||
"engines": { | ||
"node": ">=18" | ||
}, | ||
"exports": { | ||
@@ -47,3 +50,2 @@ ".": { | ||
"types": "dist/node/index.d.mts", | ||
"type": "module", | ||
"homepage": "https://xylabs.com", | ||
@@ -58,4 +60,12 @@ "license": "LGPL-3.0-only", | ||
}, | ||
"keywords": [ | ||
"typeof", | ||
"xylabs", | ||
"utility", | ||
"typescript", | ||
"esm" | ||
], | ||
"sideEffects": false, | ||
"version": "2.13.20" | ||
"version": "2.13.21", | ||
"type": "module" | ||
} |
@@ -6,8 +6,10 @@ import { typeOf } from './typeOf' | ||
case 'undefined': | ||
case 'null': | ||
case 'null': { | ||
break | ||
default: | ||
} | ||
default: { | ||
func(value) | ||
return value | ||
} | ||
} | ||
} |
@@ -6,5 +6,6 @@ import { typeOf } from './typeOf' | ||
switch (typeOf(value)) { | ||
case typeName: | ||
case typeName: { | ||
return !isFunc || isFunc(value as T) ? trueFunc(value as T) : undefined | ||
} | ||
} | ||
} |
@@ -6,4 +6,5 @@ import { typeOf } from './typeOf' | ||
switch (typeOf(value)) { | ||
case typeName: | ||
case typeName: { | ||
return [value, []] | ||
} | ||
default: { | ||
@@ -10,0 +11,0 @@ if (optional && typeOf(value) === 'undefined') { |
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
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
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
42658
356