Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@awesomeeng/awesome-utils

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@awesomeeng/awesome-utils - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

RELEASE_NOTES.md

2

package.json
{
"name": "@awesomeeng/awesome-utils",
"version": "1.2.0",
"version": "1.3.0",
"author": "the awesome engineering company",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -5,2 +5,5 @@ // (c) 2018, The Awesome Engineering Company, https://awesomeneg.com

const assert = require("assert");
/**

@@ -55,2 +58,13 @@ * Object utility functions.

deepStrictEqual(a,b) {
try {
assert.deepStrictEqual(a,b);
return true;
}
catch (ex) {
if (ex instanceof assert.AssertionError) return false;
throw ex;
}
}
/**

@@ -57,0 +71,0 @@ * Call Object.freeze() on the object and each property of the

@@ -12,7 +12,9 @@ // (c) 2018, The Awesome Engineering Company, https://awesomeneg.com

*
* @param {number} ms
* @param {number} duration
* @return {Promise}
*/
sleep(ms) {
if (!ms) return Promise.resolve();
sleep(duration) {
if (!duration && duration!==0) throw new Error("Missing duration.");
if (typeof duration!=="number") throw new Error("Invalid duration.");
if (!duration) return Promise.resolve();
return new Promise((resolve,reject)=>{

@@ -22,3 +24,3 @@ try {

resolve();
},ms);
},duration);
}

@@ -32,20 +34,38 @@ catch (ex) {

/**
* Execute an array of Promises in serial order. Resolve when
* all have resolve. Reject when any reject. Reject will short
* circuit and any remaining promises after one rejects will
* not be executed.
* Execute the given function for each cell of the array, in series order.
* If the given function returns a Promise, the promise will await resolution
* before the function is called next. This creates a series execution of
* an array of Promise executions. On a reject, all remaining executions
* are skipped.
*
* The given function is called with the signature
* f(item,index,originalArray,resultsArray).
*
* @param {Array<Promise>} array
* @param {Function} f
* @return {Promise}
*/
series(array) {
if (!array || array.length<1) return Promise.resolve();
series(array,f) {
if (!array) throw new Error("Missing array.");
if (!(array instanceof Array)) throw new Error("Invalid array.");
if (!f) throw new Error("Missing function.");
if (!(f instanceof Function)) throw new Error("Invalid function.");
if (array.length<1) return Promise.resolve([]);
let items = [].concat(array);
let results = [];
let index = -1;
return new Promise((resolve,reject)=>{
try {
const next = async function next() {
if (items.length<1) return resolve();
let p = items.shift();
if (p instanceof Promise) await p;
if (items.length<1) return resolve(results);
index += 1;
let item = items.shift();
let result = f(item,index,array,results);
if (result instanceof Promise) result = await result;
results[index] = result;
setImmediate(next);

@@ -52,0 +72,0 @@ };

@@ -5,2 +5,4 @@ // (c) 2018, The Awesome Engineering Company, https://awesomeneg.com

const Crypto = require("crypto");
class RandomUtils {

@@ -36,4 +38,323 @@ integer(min,max) {

mountain() {
return MOUNTAINS[this.integer(0,MOUNTAINS.length)];
}
uuid(bytes=16,separated=false) {
let uuid = Crypto.rng(bytes).toString("hex");
if (!separated) return uuid;
return (uuid.slice(0,8)+"-"+uuid.slice(8,12)+"-"+uuid.slice(12,16)+"-"+uuid.slice(16,20)+"-"+uuid.slice(20));
}
}
const MOUNTAINS = [
"AnthracitePeak",
"AntoraPeak",
"ArgentinePeak",
"ArrowPeak",
"AspenMountain",
"AtlanticPea",
"BadgerMountain",
"BaldMountain",
"BardPeak",
"BearPeak",
"BennettPeak",
"BerrianMountain",
"BillWilliamsPeak",
"BisonMountain",
"BlancaPea",
"BlairMountain",
"BlancaPeak",
"BlancoPoint",
"BlodgettPeak",
"BraddockPeak",
"BuffaloPeak",
"BushnellPeak",
"CaliforniaPeak",
"CapitolPeak",
"CastlePea",
"CarbonPeak",
"CarbonateMountain",
"CascoPeak",
"CastleRock",
"CathedralPeak",
"ChairMountain",
"ChalkBenchmark",
"ChallengerPoint",
"CheyenneMountain",
"ChiefCheleyPeak",
"ClarkPeak",
"ClintonPeak",
"ColumbiaPoint",
"ColumbusMountain",
"ConejosPeak",
"ConundrumPeak",
"CrestonePea",
"CraterPeak",
"CrestedButte",
"CrestoneNeedle",
"CrestonePeak",
"CrestoneEastPeak",
"CroninPeak",
"CrystalPeak",
"CulebraPeak",
"DallasPeak",
"DawsonButte",
"DeAnzaPeak",
"DevilsHead",
"DevilsPlayground",
"DiamondPeak",
"DoloresPeak",
"DyerMountain",
"EastBeckwithMountain",
"EastSpanishPeak",
"ElDientePeak",
"EldoradoMountain",
"ElectricPeak",
"ElkMountain",
"EllingwoodPoint",
"ElliottMountain",
"FishersPea",
"EmeraldPeak",
"EngelmannPeak",
"FairchildMountain",
"FishersPeak",
"FlagstaffMountain",
"FlatTopMountain",
"FletcherMountain",
"FrenchMountain",
"GarfieldPeak",
"GeminiPea",
"GilpinPeak",
"GladstonePeak",
"GraysPea",
"GoatHill",
"GothicMountain",
"GrahamPeak",
"GrandHogbac",
"GrannysNipple",
"GraysPeak",
"GreenMountain",
"GreenhornMountain",
"GreyrockMountain",
"GrizzlyPeak",
"HagermanPeak",
"HahnsPeak",
"HaguesPeak",
"HalfPeak",
"HallettPeak",
"HandiesPeak",
"HenryMountain",
"HesperusMountain",
"HorseMountain",
"HorseflyPeak",
"HorseshoeMountain",
"HorsetoothMountain",
"HuerfanoButte",
"HumboldtPeak",
"HuntsmanRidge",
"HuronPeak",
"IceMountain",
"IowaPea",
"IronMountain",
"ItalianMountain",
"JacquePeak",
"JaggedMountain",
"JamesPeak",
"JonesMountain",
"LaPlataPea",
"JupiterMountain",
"KitCarsonMountain",
"KnobbyCrest",
"LaPlataPeak",
"LavenderPeak",
"LeadMountain",
"LeonPeak",
"LittleBearPeak",
"LittleCone",
"LizardHead",
"LongsPea",
"LoneCone",
"LoneEaglePeak",
"LongBranchBaldy",
"LongScraggyPeak",
"LongsPeak",
"LookoutMountain",
"MarcellinaMountain",
"MaroonPeak",
"MatchlessMountain",
"MatterhornPeak",
"McCurdyMountain",
"MenefeePeak",
"MeridianPeak",
"MethodistMountain",
"MiddlePeak",
"MissouriMountain",
"MountAdams",
"MountAlice",
"MountAntero",
"MountAudubon",
"MountBailey",
"MountBelford",
"MountBierstadt",
"MountBlaurock",
"MountBross",
"MountBuckskin",
"MountCameron",
"MountCentennial",
"MountElber",
"MountHarvard",
"MountLincoln",
"MountMassive",
"MountSneffels",
"MountChiquita",
"MountColumbia",
"MountDemocrat",
"MountEdwards",
"MountElbert",
"MountEmmons",
"MountEolus",
"MountEvans",
"MountGuero",
"MountGunnison",
"MountGuyot",
"MountHarvard",
"MountHerard",
"MountHope",
"MountIda",
"MountJackson",
"MountJulian",
"MountLamborn",
"MountLincoln",
"MountLindsey",
"MountMassive",
"MountMcConnel",
"MountMeeker",
"MountMestas",
"MountMorrison",
"MountoftheHolyCross",
"MountOklahoma",
"MountOso",
"MountOuray",
"MountOwen",
"MountOxford",
"MountParnassus",
"MountPowell",
"MountPrinceton",
"MountRichthofen",
"MountRosa",
"MountShavano",
"MountSherman",
"MountSilverheels",
"MountSneffels",
"MountSniktau",
"MountSopris",
"MountSpaldin",
"MountWerner",
"MountWilson",
"MountYale",
"MountZion",
"MountZirkel",
"MountZwischen",
"MummyMountain",
"NeedleRock",
"NiagaraPeak",
"NokhuCrags",
"NorthArapahoPeak",
"NorthEolus",
"NorthMammPeak",
"NorthMaroonPeak",
"NorthTableMountain",
"OurayPeak",
"PacificPeak",
"ParkCone",
"ParkviewMountain",
"ParryPeak",
"Peak10",
"Peak13762",
"PetitGrepon",
"PikesPea",
"PettingellPeak",
"PhoenixPeak",
"PigeonPeak",
"PikesPeak",
"PiñonMesaHighPoint",
"PtarmiganPeak",
"PumaPeak",
"PyramidPeak",
"QuandaryPeak",
"RedMountain",
"RedPeak",
"RedTableMountain",
"RedcloudPeak",
"RioGrandePyramid",
"RitoAltoPeak",
"SanLuisPeak",
"SandMountainNorth",
"SawtoothMountain",
"SevenUtesMountain",
"SharkstoothPeak",
"ShawneePeak",
"SheepMountain",
"SilverKingPeak",
"SilverMountain",
"SleepyCatPeak",
"SnowmassMountain",
"SnowmassPeak",
"SouthBaldMountain",
"SouthBrossPeak",
"SouthRiverPeak",
"SouthTableMountain",
"SpecimenMountain",
"StaticPeak",
"StewartPeak",
"StormKingMountain",
"StormPeak",
"SultanMountain",
"SummitPeak",
"SunlightPeak",
"SunlightSpire",
"SunshinePeak",
"TabeguachePeak",
"TanksPeak",
"TaylorPeak",
"TeakettleMountain",
"TerribleMountai",
"TheDiamond",
"TheHorns",
"TheSawtooth",
"ThirtynineMileMountain",
"ThunderButte",
"TijerasPeak",
"TomichiDome",
"TorreysPeak",
"TowerMountain",
"TraverPea",
"TreasureMountain",
"TrinityPeak",
"UncompahgrePeak",
"SpanishPeaks",
"TurretPeak",
"TwilightPeak",
"TwinSistersPeaks",
"TwoButtes",
"UncompahgrePeak",
"UtePeak",
"VermilionPeak",
"VestalPeak",
"WaughMountain",
"WestBuffaloPeak",
"WestElkPeak",
"WestSpanishPeak",
"WetterhornPeak",
"WhetstoneMountain",
"WilliamsPeak",
"WilsonPeak",
"WindomPeak",
"WindyPeak",
"WinfieldPeak",
"YpsilonMountain",
"ZenobiaPeak",
];
module.exports = new RandomUtils();

@@ -13,3 +13,3 @@ // (c) 2018, The Awesome Engineering Company, https://awesomeneg.com

describe("DateUtils",function(){
describe("AwesomeUtils.Date",function(){
it("constants",function(){

@@ -16,0 +16,0 @@ assert.equal(DateUtils.SECOND,1000);

@@ -13,3 +13,3 @@ // (c) 2018, The Awesome Engineering Company, https://awesomeneg.com

describe("ObjectUtils",function(){
describe("AwesomeUtils.Object",function(){
let base = {

@@ -80,2 +80,14 @@ one: {

it("deepStrictEqual",function(){
assert(ObjectUtils.deepStrictEqual(1,1));
assert(ObjectUtils.deepStrictEqual("1","1"));
assert(ObjectUtils.deepStrictEqual([1],[1]));
assert(ObjectUtils.deepStrictEqual({one:1},{one:1}));
assert(ObjectUtils.deepStrictEqual({one:1,two:{three:{four:234}}},{one:1,two:{three:{four:234}}}));
assert(!ObjectUtils.deepStrictEqual(1,2));
assert(!ObjectUtils.deepStrictEqual("1","2"));
assert(!ObjectUtils.deepStrictEqual([1],[2]));
assert(!ObjectUtils.deepStrictEqual({one:1},{one:2}));
});
it("deepFreeze",function(){

@@ -82,0 +94,0 @@ let obj = {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc