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.5.0 to 1.5.1-beta-1

tsconfig.json

0

.eslintrc.js

@@ -0,0 +0,0 @@ "use strict";

@@ -144,3 +144,8 @@ ## Classes

### dateUtils.floor(date, to) ⇒ <code>Date</code>
Given some date, floor it to the nearest `to` argument, where `to` is some number of milliseconds. For example, to floor to the nearest minute you would do `floor(date,60000)` where `60000` is the number of milliseconds in a single date. You can use this in conjunction with `SECOND`, `MINUTE`, `HOUR`, and `DAY`. See also `floorSecond()`, `floorMinute()`, `floorHour()`, and `floorDay()` below.
Given some date, floor it to the nearest `to` argument, where `to` is some
number of milliseconds. For example, to floor to the nearest minute you
would do `floor(date,60000)` where `60000` is the number of milliseconds in
a single date. You can use this in conjunction with `SECOND`, `MINUTE`,
`HOUR`, and `DAY`. See also `floorSecond()`, `floorMinute()`, `floorHour()`,
and `floorDay()` below.

@@ -216,4 +221,9 @@ **Kind**: instance method of [<code>DateUtils</code>](#DateUtils)

### dateUtils.from(date) ⇒ <code>Date</code>
Given some date or date line object, return a Date object. This allows you to quickly move between different types of date like objects. It will parse nubmers as a unix epoch, a string of numbers as a unix epoch, JS Date object as a Date Object, or a String as a `Date.parse()` call. Basically, it does its best to retunr a Date Object or an exception.
Given some date or date line object, return a Date object. This allows
you to quickly move between different types of date like objects. It
will parse numbers as a unix epoch, a string of numbers as a unix epoch,
JS Date object as a Date Object, or a String as a `Date.parse()` call.
Basically, it does its best to return a Date Object or an exception.
**Kind**: instance method of [<code>DateUtils</code>](#DateUtils)

@@ -245,4 +255,44 @@

### dateUtils.format(date, pattern) ⇒ <code>string</code>
Format a given date using a given pattern. Patterns are built using the following chart similar to how momentjs, datejs, php strftime, Java SimpleDateFormat, etc. You use one or more of the patterns from above to create a pattern. You may also use literals in your pattern like `YYYYMMDD'T'HHMMSSSSS'ZULU'` where both 'T' and 'ZULU' are literals and are inserted verbatim. | Pattern | Substitution | Example against July 20, 1969, 20:18:04.017 UTC | |---------|------------------------------------------|-------------------------------------------------| | YY | 2 digit year. | 69 | | YYYY | 4 digit year. | 1969 | | M | numeric month, not zero filled. | 7 | | MM | numeric month, zero filled. | 07 | | MMM | shortened 3 character month name. | Jul | | MMMM | full month name | July | | D | numeric day of month, not zero filled. | 20 | | DD | numeric day of month, zero filled. | 20 | | DDD | numeric day of year, not zero filled. | 200 | | DDDD | numeric day of year, zero filled. | 200 | | d | numeric day of the week (0=sunday). | 0 | | dd | shortened 2 character day of the week | Su | | ddd | shortened 3 character day of the week | Sun | | dddd | full textual day of the week | Sunday | | A | AM or PM. | PM | | a | am or pm. | pm | | H | 24 0 based hour of day, not zero filled. | 20 | | HH | 24 0 based hour of day, zero filled. | 20 | | h | 12 hour of day, not zero filled. | 8 | | hh | 12 hour of day, zero filled. | 8 | | k | 24 1 based hour of day, not zero filled. | 21 | | kk | 24 1 based hour of day, zero filled. | 21 | | m | minute of hour, not zero filled. | 18 | | mm | minute of hour, zero filled. | 18 | | s | second of minute, not zero filled. | 4 | | ss | second of minute, zero filled. | 04 | | S | milliseconds of second, not zero filled. | 17 | | SSS | milliseconds of second, zero filled. | 017 | | z | textual time zone | UTC | | Z | relative time zone with separator | -00:00 | | ZZ | relative time zone without separator | -0000 | | X | unix timestamp (seconds) | -14182916 | | x | unix timestamp (milliseconds) | -14182916000 |
Format a given date using a given pattern. Patterns are built using the following chart similar to
how momentjs, datejs, php strftime, Java SimpleDateFormat, etc.
You use one or more of the patterns from above to create a pattern. You may also use literals in your
pattern like `YYYYMMDD'T'HHMMSSSSS'ZULU'` where both 'T' and 'ZULU' are literals and are inserted verbatim.
| Pattern | Substitution | Example against July 20, 1969, 20:18:04.017 UTC |
|---------|------------------------------------------|-------------------------------------------------|
| YY | 2 digit year. | 69 |
| YYYY | 4 digit year. | 1969 |
| M | numeric month, not zero filled. | 7 |
| MM | numeric month, zero filled. | 07 |
| MMM | shortened 3 character month name. | Jul |
| MMMM | full month name | July |
| D | numeric day of month, not zero filled. | 20 |
| DD | numeric day of month, zero filled. | 20 |
| DDD | numeric day of year, not zero filled. | 200 |
| DDDD | numeric day of year, zero filled. | 200 |
| d | numeric day of the week (0=sunday). | 0 |
| dd | shortened 2 character day of the week | Su |
| ddd | shortened 3 character day of the week | Sun |
| dddd | full textual day of the week | Sunday |
| A | AM or PM. | PM |
| a | am or pm. | pm |
| H | 24 0 based hour of day, not zero filled. | 20 |
| HH | 24 0 based hour of day, zero filled. | 20 |
| h | 12 hour of day, not zero filled. | 8 |
| hh | 12 hour of day, zero filled. | 8 |
| k | 24 1 based hour of day, not zero filled. | 21 |
| kk | 24 1 based hour of day, zero filled. | 21 |
| m | minute of hour, not zero filled. | 18 |
| mm | minute of hour, zero filled. | 18 |
| s | second of minute, not zero filled. | 4 |
| ss | second of minute, zero filled. | 04 |
| S | milliseconds of second, not zero filled. | 17 |
| SSS | milliseconds of second, zero filled. | 017 |
| z | textual time zone | UTC |
| Z | relative time zone with separator | -00:00 |
| ZZ | relative time zone without separator | -0000 |
| X | unix timestamp (seconds) | -14182916 |
| x | unix timestamp (milliseconds) | -14182916000 |
**Kind**: instance method of [<code>DateUtils</code>](#DateUtils)

@@ -308,4 +358,12 @@

### moduleUtils.unrequire(mod, [removeChildren]) ⇒ <code>number</code>
Removes a module from the require cache, thus making it reload again if required. Also, any children that were loaded by the given module are also removed. Returns the total number of modules removed. You may optional indicate if the unrequire should remove dependant children as well. This can have unwanted side-effects so use with caution.
Removes a module from the require cache, thus making it
reload again if required. Also, any children that
were loaded by the given module are also removed.
Returns the total number of modules removed.
You may optional indicate if the unrequire should remove
dependant children as well. This can have unwanted side-effects
so use with caution.
**Kind**: instance method of [<code>ModuleUtils</code>](#ModuleUtils)

@@ -324,4 +382,10 @@

### moduleUtils.moduleSource(depth) ⇒ <code>string</code>
Returns the filename of the code that called this function. This works by throwing and catching an exception and then reading the stack trace of the exception and finding the info it needs. *depth* specifies how far back into the stack we should go. So if you want the caller of this function, set it to 0 (or omit it). If you want the caller of the caller of this function, set it to 1. etc.
Returns the filename of the code that called this function.
This works by throwing and catching an exception and then reading the stack
trace of the exception and finding the info it needs.
*depth* specifies how far back into the stack we should go. So if you want
the caller of this function, set it to 0 (or omit it). If you want the
caller of the caller of this function, set it to 1. etc.
**Kind**: instance method of [<code>ModuleUtils</code>](#ModuleUtils)

@@ -339,4 +403,8 @@

### moduleUtils.moduleStack(mod, [start], [end]) ⇒ <code>Array.&lt;String&gt;</code>
Returns the module require stack for the given module. That is, how was the given module imported (required) into the current execution. This returns an array of strings, which are the module ancestor module.id values.
Returns the module require stack for the given module. That is, how
was the given module imported (required) into the current execution.
This returns an array of strings, which are the module
ancestor module.id values.
**Kind**: instance method of [<code>ModuleUtils</code>](#ModuleUtils)

@@ -375,3 +443,4 @@

### objectUtils.isPlainObject(obj) ⇒ <code>Boolean</code>
Returns true oif the given object is a "plain" javascript object, meaning it doesnt inherit from some other type of js object like an array, date, error, etc.
Returns true oif the given object is a "plain" javascript object, meaning it
doesn't inherit from some other type of js object like an array, date, error, etc.

@@ -405,3 +474,4 @@ **Kind**: instance method of [<code>ObjectUtils</code>](#ObjectUtils)

### objectUtils.deepFreeze(obj) ⇒ <code>void</code>
Call Object.freeze() on the object and each property of the object, essentially freezing the entire structure.
Call Object.freeze() on the object and each property of the
object, essentially freezing the entire structure.

@@ -503,3 +573,4 @@ **Kind**: instance method of [<code>ObjectUtils</code>](#ObjectUtils)

### promiseUtils.sleep(duration) ⇒ <code>Promise</code>
Creates a promise that resolves after n milliseconds. Great for usage with await for delaying some period of time.
Creates a promise that resolves after n milliseconds. Great for usage
with await for delaying some period of time.

@@ -518,4 +589,11 @@ **Kind**: instance method of [<code>PromiseUtils</code>](#PromiseUtils)

### promiseUtils.series(array, f) ⇒ <code>Promise</code>
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).
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).
**Kind**: instance method of [<code>PromiseUtils</code>](#PromiseUtils)

@@ -534,4 +612,10 @@

### promiseUtils.timeout(promise, [ttl], [timeoutException]) ⇒ <code>Promise</code>
In essence this lets you wrap a promise in a timeout such that if the timeout occurs before the promise resolves or reject, this rejects. Returns a promise that will resolve/reject if the passed in promise resolves or rejects before the passed in ttl time has elapsed. If the ttl time does elsapse, the returned promise will reject (with the optional exception) and the passed in promise resolve or reject will be swallowed.
In essence this lets you wrap a promise in a timeout such that if the
timeout occurs before the promise resolves or reject, this rejects.
Returns a promise that will resolve/reject if the passed in promise resolves
or rejects before the passed in ttl time has elapsed. If the ttl time does
elsapse, the returned promise will reject (with the optional exception) and
the passed in promise resolve or reject will be swallowed.
**Kind**: instance method of [<code>PromiseUtils</code>](#PromiseUtils)

@@ -567,4 +651,10 @@

### vmUtils.executionLine(depth) ⇒ <code>number</code>
Returns the line number of the code of the line that called the line() function. This works by throwing and catching an exception and then reading the stack trace of the exception and finding the info it needs. *depth* specifies how far back into the stack we should go. So if you want the caller of this function, set it to 0 (or omit it). If you want the caller of the caller of this function, set it to 1. etc.
Returns the line number of the code of the line that called the line() function.
This works by throwing and catching an exception and then reading the stack
trace of the exception and finding the info it needs.
*depth* specifies how far back into the stack we should go. So if you want
the caller of this function, set it to 0 (or omit it). If you want the
caller of the caller of this function, set it to 1. etc.
**Kind**: instance method of [<code>VMUtils</code>](#VMUtils)

@@ -582,4 +672,10 @@

### vmUtils.executionSource(depth) ⇒ <code>string</code>
Returns the filename of the code that called this function. This works by throwing and catching an exception and then reading the stack trace of the exception and finding the info it needs. *depth* specifies how far back into the stack we should go. So if you want the caller of this function, set it to 0 (or omit it). If you want the caller of the caller of this function, set it to 1. etc.
Returns the filename of the code that called this function.
This works by throwing and catching an exception and then reading the stack
trace of the exception and finding the info it needs.
*depth* specifies how far back into the stack we should go. So if you want
the caller of this function, set it to 0 (or omit it). If you want the
caller of the caller of this function, set it to 1. etc.
**Kind**: instance method of [<code>VMUtils</code>](#VMUtils)

@@ -597,4 +693,10 @@

### vmUtils.executionSourceAndLine(depth) ⇒ <code>string</code>
Returns the filename and line number of the code that called this function. This works by throwing and catching an exception and then reading the stack trace of the exception and finding the info it needs. *depth* specifies how far back into the stack we should go. So if you want the caller of this function, set it to 0 (or omit it). If you want the caller of the caller of this function, set it to 1. etc.
Returns the filename and line number of the code that called this function.
This works by throwing and catching an exception and then reading the stack
trace of the exception and finding the info it needs.
*depth* specifies how far back into the stack we should go. So if you want
the caller of this function, set it to 0 (or omit it). If you want the
caller of the caller of this function, set it to 1. etc.
**Kind**: instance method of [<code>VMUtils</code>](#VMUtils)

@@ -612,4 +714,19 @@

### vmUtils.executionStack([start], [end]) ⇒ <code>Array.&lt;Object&gt;</code>
Returns the currently running stack trace, as an array of objects (see below) that describes where in the current execution stack the application currently is. The returned array is comprised of stack entry objects which have the following shape: ``` entry = { entry: string - the full stack trace entry string method: the method name from the stack trace entry source: the filename the method is in line: the line number the execution is on position: the line position the execution is on } ```
Returns the currently running stack trace, as an array of objects (see below)
that describes where in the current execution stack the application
currently is.
The returned array is comprised of stack entry objects which
have the following shape:
```
entry = {
entry: string - the full stack trace entry string
method: the method name from the stack trace entry
source: the filename the method is in
line: the line number the execution is on
position: the line position the execution is on
}
```
**Kind**: instance method of [<code>VMUtils</code>](#VMUtils)

@@ -616,0 +733,0 @@

97

package.json
{
"name": "@awesomeeng/awesome-utils",
"version": "1.5.0",
"author": "the awesome engineering company",
"license": "MIT",
"contributors": [
"Glen R. Goodwin"
],
"main": "./src/AwesomeUtils.js",
"engines": {
"node": ">=10.5.0"
},
"dependencies": {},
"devDependencies": {
"eslint": "^6.6.0",
"jsdoc-to-markdown": "^5.0.2",
"mocha": "^6.2.1"
},
"optionalDependencies": {},
"scripts": {
"lint": "eslint src test",
"docs": "jsdoc2md src/** --separators > docs/API.md",
"test": "mocha test",
"tests": "mocha test"
},
"description": "Javascript Utility functions for enterprise nodejs applications.",
"directories": {
"doc": "docs",
"test": "test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/awesomeeng/awesome-utils.git"
},
"keywords": [
"awesome",
"awesomeeng",
"awesome",
"engineering",
"utilities",
"utility",
"utils",
"util"
],
"bugs": {
"url": "https://github.com/awesomeeng/awesome-utils/issues"
},
"homepage": "https://github.com/awesomeeng/awesome-utils#readme"
}
"name": "@awesomeeng/awesome-utils",
"version": "1.5.1-beta-1",
"author": "the awesome engineering company",
"license": "MIT",
"contributors": [
"Glen R. Goodwin"
],
"main": "./src/AwesomeUtils.js",
"types": "./types/AwesomeUtils.d.ts",
"engines": {
"node": ">=10.5.0"
},
"devDependencies": {
"eslint": "^8.8.0",
"jsdoc-to-markdown": "^7.1.1",
"mocha": "^9.2.0",
"typescript": "^4.5.5"
},
"scripts": {
"build": "tsc",
"lint": "eslint src test",
"docs": "jsdoc2md src/** --separators > docs/API.md",
"test": "mocha test",
"tests": "mocha test"
},
"description": "Javascript Utility functions for enterprise nodejs applications.",
"directories": {
"doc": "docs",
"test": "test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/awesomeeng/awesome-utils.git"
},
"keywords": [
"awesome",
"awesomeeng",
"awesome",
"engineering",
"utilities",
"utility",
"utils",
"util"
],
"bugs": {
"url": "https://github.com/awesomeeng/awesome-utils/issues"
},
"homepage": "https://github.com/awesomeeng/awesome-utils#readme"
}
# AwesomeUtils Release Notes
#### **Version 1.5.1**
- updated dependencies.
- Fixes an error where null values would be returned as undefined when using Object.get.
#### **Version 1.5.0**

@@ -4,0 +10,0 @@

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

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

@@ -0,19 +1,37 @@

const ANSI = require("./ANSI.js");
const Array = require("./Array.js");
const Class = require("./Class.js");
const Comparator = require("./Comparator.js");
const Date = require("./Date.js");
const FS = require("./FS.js");
const MimeTypes = require("./MimeTypes.js");
const Module = require("./Module.js");
const Net = require("./Net.js");
const Object = require("./Object.js");
const Parser = require("./Parser.js");
const Promise = require("./Promise.js");
const Random = require("./Random.js");
const Request = require("./Request.js");
const Sequence = require("./Sequence.js");
const VM = require("./VM.js");
const Workers = require("./Workers.js");
module.exports = {
ANSI: require("./ANSI.js"),
Array: require("./Array.js"),
Class: require("./Class.js"),
Comparator: require("./Comparator.js"),
Date: require("./Date.js"),
FS: require("./FS.js"),
MimeTypes: require("./MimeTypes.js"),
Module: require("./Module.js"),
Net: require("./Net.js"),
Object: require("./Object.js"),
Parser: require("./Parser.js"),
Promise: require("./Promise.js"),
Random: require("./Random.js"),
Request: require("./Request.js"),
Sequence: require("./Sequence.js"),
VM: require("./VM.js"),
Workers: require("./Workers.js")
ANSI,
Array,
Class,
Comparator,
Date,
FS,
MimeTypes,
Module,
Net,
Object,
Parser,
Promise,
Random,
Request,
Sequence,
VM,
Workers,
};

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

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

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

* you to quickly move between different types of date like objects. It
* will parse nubmers as a unix epoch, a string of numbers as a unix epoch,
* will parse numbers as a unix epoch, a string of numbers as a unix epoch,
* JS Date object as a Date Object, or a String as a `Date.parse()` call.
*
* Basically, it does its best to retunr a Date Object or an exception.
* Basically, it does its best to return a Date Object or an exception.
*

@@ -162,0 +162,0 @@ * @param {Date|number|string}

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

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

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

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

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

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

* Returns true oif the given object is a "plain" javascript object, meaning it
* doesnt inherit from some other type of js object like an array, date, error, etc.
* doesn't inherit from some other type of js object like an array, date, error, etc.
*

@@ -130,4 +130,4 @@ * @param {Object} obj

get(obj,path,defaultValue=undefined,delimiter=".") {
if (obj==undefined || obj===null) return undefined;
if (path=== undefined || path===null || path==="") return obj===undefined ? defaultValue : obj;
if (obj===undefined || obj===null) return obj;
if (path===undefined || path===null || path==="") return obj===undefined ? defaultValue : obj;
if (!(path instanceof Array)) path = ""+path;

@@ -154,4 +154,4 @@ if (typeof path==="string") path = path.split(delimiter);

set(obj,path,value,delimiter=".") {
if (obj==undefined || obj===null) return obj;
if (path=== undefined || path===null || path==="") return obj;
if (obj===undefined || obj===null) return obj;
if (path===undefined || path===null || path==="") return obj;
if (!(path instanceof Array)) path = ""+path;

@@ -158,0 +158,0 @@ if (typeof path==="string") path = path.split(delimiter);

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

// We do this so typescript can get the typings.
/**
* @type Class
*/
get AbstractParser() {

@@ -74,3 +78,3 @@ return AbstractParser;

set pos(n) {
return this.position = n;
this.position = n;
}

@@ -83,3 +87,3 @@

set index(n) {
return this.position = n;
this.position = n;
}

@@ -86,0 +90,0 @@

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

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

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

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

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

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

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

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

});
// test to make sure get returns the correct type for falsey values.
assert.deepStrictEqual(ObjectUtils.get({
one: null
},"one"),null);
assert.deepStrictEqual(ObjectUtils.get({
one: undefined
},"one"),undefined);
assert.deepStrictEqual(ObjectUtils.get({
one: 0
},"one"),0);
assert.deepStrictEqual(ObjectUtils.get({
one: ''
},"one"),'');
assert.deepStrictEqual(ObjectUtils.get({
one: false
},"one"),false);
});

@@ -133,0 +150,0 @@

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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