@banklessdao/util-misc
Advanced tools
Comparing version 2021.0.1-BETA to 2021.0.2-BETA
{ | ||
"name": "@banklessdao/util-misc", | ||
"version": "2021.0.1-BETA", | ||
"version": "2021.0.2-BETA", | ||
"description": "Miscellaneous utilities.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/BanklessDAO/content-gateway", |
@@ -0,5 +1,8 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.hasSameElements = void 0; | ||
/** | ||
* Tells whether the two arrays have the same elements (not necessarily in the same order). | ||
*/ | ||
export const hasSameElements = (arr0, arr1) => { | ||
const hasSameElements = (arr0, arr1) => { | ||
if (arr0.length !== arr1.length) | ||
@@ -9,2 +12,3 @@ return false; | ||
}; | ||
exports.hasSameElements = hasSameElements; | ||
//# sourceMappingURL=Arrays.js.map |
@@ -0,13 +1,18 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.base64Decode = exports.base64Encode = void 0; | ||
/** | ||
* Encodes an utf-8 string to a base64 string. | ||
*/ | ||
export const base64Encode = (str) => { | ||
const base64Encode = (str) => { | ||
return Buffer.from(str, "utf-8").toString("base64"); | ||
}; | ||
exports.base64Encode = base64Encode; | ||
/** | ||
* Decodes a base64 string to an utf-8 string. | ||
*/ | ||
export const base64Decode = (str) => { | ||
const base64Decode = (str) => { | ||
return Buffer.from(str, "base64").toString("utf8"); | ||
}; | ||
exports.base64Decode = base64Decode; | ||
//# sourceMappingURL=Base64.js.map |
@@ -1,2 +0,5 @@ | ||
import * as E from "fp-ts/Either"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.extractLeft = exports.extractRight = void 0; | ||
const E = require("fp-ts/Either"); | ||
/** | ||
@@ -6,3 +9,3 @@ * Tries to extract a Right value from an Either or throws an exception. | ||
*/ | ||
export const extractRight = (either) => { | ||
const extractRight = (either) => { | ||
if (E.isLeft(either)) { | ||
@@ -15,2 +18,3 @@ throw new Error("The supplied either was a Left"); | ||
}; | ||
exports.extractRight = extractRight; | ||
/** | ||
@@ -20,3 +24,3 @@ * Tries to extract a Left value from an Either or throws an exception. | ||
*/ | ||
export const extractLeft = (either) => { | ||
const extractLeft = (either) => { | ||
if (E.isLeft(either)) { | ||
@@ -29,2 +33,3 @@ return either.left; | ||
}; | ||
exports.extractLeft = extractLeft; | ||
//# sourceMappingURL=Either.js.map |
export * from "./Arrays"; | ||
export * from "./Base64"; | ||
export * from "./Either"; | ||
export * from "./Logging"; | ||
export * from "./Tagged"; | ||
export * from "./Utils"; |
@@ -1,6 +0,10 @@ | ||
export * from "./Arrays"; | ||
export * from "./Base64"; | ||
export * from "./Logging"; | ||
export * from "./Tagged"; | ||
export * from "./Utils"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./Arrays"), exports); | ||
tslib_1.__exportStar(require("./Base64"), exports); | ||
tslib_1.__exportStar(require("./Either"), exports); | ||
tslib_1.__exportStar(require("./Logging"), exports); | ||
tslib_1.__exportStar(require("./Tagged"), exports); | ||
tslib_1.__exportStar(require("./Utils"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,5 @@ | ||
import { Logger } from "tslog"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createLogger = void 0; | ||
const tslog_1 = require("tslog"); | ||
/** | ||
@@ -6,3 +9,3 @@ * Creates a new tslog {@link Logger} object with the given `name` | ||
*/ | ||
export const createLogger = (name) => new Logger({ | ||
const createLogger = (name) => new tslog_1.Logger({ | ||
name: name, | ||
@@ -12,2 +15,3 @@ printLogMessageInNewLine: true, | ||
}); | ||
exports.createLogger = createLogger; | ||
//# sourceMappingURL=Logging.js.map |
@@ -1,10 +0,14 @@ | ||
import { __rest } from "tslib"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.untag = void 0; | ||
const tslib_1 = require("tslib"); | ||
/** | ||
* Removes the __tag from a previously tagged object. | ||
*/ | ||
export const untag = (t) => { | ||
const untag = (t) => { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const { __tag } = t, rest = __rest(t, ["__tag"]); | ||
const { __tag } = t, rest = tslib_1.__rest(t, ["__tag"]); | ||
return rest; | ||
}; | ||
exports.untag = untag; | ||
//# sourceMappingURL=Tagged.js.map |
@@ -0,17 +1,22 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.coercePrimitive = exports.programError = exports.notEmpty = void 0; | ||
/** | ||
* Type guard for a value `T` that will only allow non-empty (non-null and non-undefined) values. | ||
*/ | ||
export function notEmpty(value) { | ||
function notEmpty(value) { | ||
return value !== null && value !== undefined; | ||
} | ||
exports.notEmpty = notEmpty; | ||
/** | ||
* Creates a new `Error` with the given `msg`. | ||
*/ | ||
export const programError = (msg) => { | ||
const programError = (msg) => { | ||
throw new Error(msg); | ||
}; | ||
exports.programError = programError; | ||
/** | ||
* Tries to convert a `string` to a primitive value (`string`, `number`, `boolean`). | ||
*/ | ||
export const coercePrimitive = (value) => { | ||
const coercePrimitive = (value) => { | ||
if (value === "true") { | ||
@@ -33,2 +38,3 @@ return true; | ||
}; | ||
exports.coercePrimitive = coercePrimitive; | ||
//# sourceMappingURL=Utils.js.map |
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
10071
192