@hephaestus/utils
Advanced tools
Comparing version 1.0.0-alpha.3 to 1.0.0-alpha.4
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ExtendedMap = void 0; | ||
var ExtendedMap = (function (_super) { | ||
__extends(ExtendedMap, _super); | ||
function ExtendedMap() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
ExtendedMap.prototype.find = function (func) { | ||
var e_1, _a; | ||
try { | ||
for (var _b = __values(this.values()), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var item = _c.value; | ||
if (func(item)) { | ||
return item; | ||
} | ||
class ExtendedMap extends Map { | ||
find(func) { | ||
for (const item of this.values()) { | ||
if (func(item)) { | ||
return item; | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
return undefined; | ||
}; | ||
ExtendedMap.prototype.filter = function (func) { | ||
var e_2, _a; | ||
var arr = []; | ||
try { | ||
for (var _b = __values(this.values()), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var item = _c.value; | ||
if (func(item)) { | ||
arr.push(item); | ||
} | ||
} | ||
filter(func) { | ||
const arr = []; | ||
for (const item of this.values()) { | ||
if (func(item)) { | ||
arr.push(item); | ||
} | ||
} | ||
catch (e_2_1) { e_2 = { error: e_2_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_2) throw e_2.error; } | ||
} | ||
return arr; | ||
}; | ||
ExtendedMap.prototype.map = function (func) { | ||
var e_3, _a; | ||
var arr = []; | ||
try { | ||
for (var _b = __values(this.values()), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var item = _c.value; | ||
arr.push(func(item)); | ||
} | ||
} | ||
map(func) { | ||
const arr = []; | ||
for (const item of this.values()) { | ||
arr.push(func(item)); | ||
} | ||
catch (e_3_1) { e_3 = { error: e_3_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_3) throw e_3.error; } | ||
} | ||
return arr; | ||
}; | ||
ExtendedMap.prototype.reduce = function (func, initialValue) { | ||
var iter = this.values(); | ||
var current = iter.next(); | ||
var result = initialValue !== null && initialValue !== void 0 ? initialValue : current.value; | ||
} | ||
reduce(func, initialValue) { | ||
const iter = this.values(); | ||
let current = iter.next(); | ||
let result = initialValue !== null && initialValue !== void 0 ? initialValue : current.value; | ||
while (!current.done) { | ||
@@ -101,44 +38,21 @@ result = func(result, current.value); | ||
return result; | ||
}; | ||
ExtendedMap.prototype.every = function (func) { | ||
var e_4, _a; | ||
try { | ||
for (var _b = __values(this.values()), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var item = _c.value; | ||
if (!func(item)) { | ||
return false; | ||
} | ||
} | ||
every(func) { | ||
for (const item of this.values()) { | ||
if (!func(item)) { | ||
return false; | ||
} | ||
} | ||
catch (e_4_1) { e_4 = { error: e_4_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_4) throw e_4.error; } | ||
} | ||
return true; | ||
}; | ||
ExtendedMap.prototype.some = function (func) { | ||
var e_5, _a; | ||
try { | ||
for (var _b = __values(this.values()), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var item = _c.value; | ||
if (func(item)) { | ||
return true; | ||
} | ||
} | ||
some(func) { | ||
for (const item of this.values()) { | ||
if (func(item)) { | ||
return true; | ||
} | ||
} | ||
catch (e_5_1) { e_5 = { error: e_5_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_5) throw e_5.error; } | ||
} | ||
return false; | ||
}; | ||
return ExtendedMap; | ||
}(Map)); | ||
} | ||
} | ||
exports.ExtendedMap = ExtendedMap; | ||
//# sourceMappingURL=extended-map.js.map |
@@ -5,5 +5,5 @@ "use strict"; | ||
function identity(list) { | ||
return list.filter(function (x) { return x != null; }); | ||
return list.filter((x) => x != null); | ||
} | ||
exports.identity = identity; | ||
//# sourceMappingURL=identity.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.warn = exports.success = exports.info = exports.error = exports.log = exports.LEVEL = void 0; | ||
var util_1 = require("util"); | ||
const util_1 = require("util"); | ||
var LEVEL; | ||
@@ -13,40 +13,22 @@ (function (LEVEL) { | ||
})(LEVEL = exports.LEVEL || (exports.LEVEL = {})); | ||
function log(content, level, stream) { | ||
if (level === void 0) { level = LEVEL.DEFAULT; } | ||
if (stream === void 0) { stream = process.stdout; } | ||
var codes = util_1.inspect.colors[level]; | ||
var text = content.join(' '); | ||
var message = codes ? "\u001B[".concat(codes[0], "m").concat(text, "\u001B[").concat(codes[1], "m") : text; | ||
stream.write(Buffer.from("ERIS_BOILER: ".concat((0, util_1.formatWithOptions)({ colors: true }, message), "\n"))); | ||
function log(content, level = LEVEL.DEFAULT, stream = process.stdout) { | ||
const codes = util_1.inspect.colors[level]; | ||
const text = content.join(' '); | ||
const message = codes ? `\x1b[${codes[0]}m${text}\x1b[${codes[1]}m` : text; | ||
stream.write(Buffer.from(`ERIS_BOILER: ${(0, util_1.formatWithOptions)({ colors: true }, message)}\n`)); | ||
} | ||
exports.log = log; | ||
function error() { | ||
var content = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
content[_i] = arguments[_i]; | ||
} | ||
function error(...content) { | ||
return log(content, LEVEL.ERROR, process.stderr); | ||
} | ||
exports.error = error; | ||
function info() { | ||
var content = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
content[_i] = arguments[_i]; | ||
} | ||
function info(...content) { | ||
return log(content, LEVEL.INFO); | ||
} | ||
exports.info = info; | ||
function success() { | ||
var content = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
content[_i] = arguments[_i]; | ||
} | ||
function success(...content) { | ||
return log(content, LEVEL.SUCCESS); | ||
} | ||
exports.success = success; | ||
function warn() { | ||
var content = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
content[_i] = arguments[_i]; | ||
} | ||
function warn(...content) { | ||
return log(content, LEVEL.WARN); | ||
@@ -53,0 +35,0 @@ } |
{ | ||
"name": "@hephaestus/utils", | ||
"version": "1.0.0-alpha.3", | ||
"version": "1.0.0-alpha.4", | ||
"description": "> TODO: description", | ||
@@ -30,3 +30,4 @@ "author": "Alex Taxiera <alex.taxiera@gmail.com>", | ||
"test": "echo \"Error: run tests from root\" && exit 1", | ||
"build": "ttsc", | ||
"build": "tsup src/index.ts --format cjs,esm --dts --clean", | ||
"build:cjs": "ttsc", | ||
"build:esm": "ttsc -p ./tsconfig.esm.json", | ||
@@ -39,3 +40,3 @@ "clean": "rm -rf dist", | ||
}, | ||
"gitHead": "27679c998b94835ea3762965c726efed5a2e8710" | ||
"gitHead": "68027d757b7f38f6c971bf91d81fb137cebba711" | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
18068
32
283