Comparing version 0.0.7 to 0.0.8
export * from "./error/caught-result"; | ||
export * from "./array/find"; | ||
export * from "./number/format"; |
@@ -1,29 +0,19 @@ | ||
function isError(error) { | ||
// TODO: Must be a better check | ||
return typeof error === "object" && !!error; | ||
} | ||
function caughtResultToError(error) { | ||
if (isError(error)) { | ||
return error; | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
return new Error(caughtResultToString(error)); | ||
} | ||
function caughtResultToString(error) { | ||
if (isError(error)) { | ||
return error.message; | ||
} | ||
if (typeof error === "string") { | ||
return error; | ||
} | ||
return String(error); | ||
} | ||
function findOnly(array, predicate, message) { | ||
const found = array.filter(predicate); | ||
if (found.length !== 1) { | ||
throw new Error(message !== null && message !== void 0 ? message : `Expected exactly one item, found ${found.length}`); | ||
} | ||
return found[0]; | ||
} | ||
export { caughtResultToError, caughtResultToString, findOnly }; | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./error/caught-result"), exports); | ||
__exportStar(require("./array/find"), exports); | ||
__exportStar(require("./number/format"), exports); |
{ | ||
"name": "@dhau/lang", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"type": "module", | ||
"description": "Various language extensions for JS", | ||
"main": "./dist/index.js", | ||
"module": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"module": "./dist/index.mjs", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.js" | ||
} | ||
"require": "./dist/index.js", | ||
"import": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
@@ -15,0 +17,0 @@ "files": [ |
6824
12
106