core-functions
Advanced tools
Comparing version 3.0.11 to 3.0.12
10
any.js
@@ -8,8 +8,8 @@ 'use strict'; | ||
*/ | ||
module.exports = { | ||
defined: defined, | ||
notDefined: notDefined, | ||
valueOf: valueOf | ||
}; | ||
module.exports.defined = defined; | ||
module.exports.notDefined = notDefined; | ||
// noinspection JSDeprecatedSymbols | ||
module.exports.valueOf = valueOf; | ||
/** | ||
@@ -16,0 +16,0 @@ * Determines whether the given value is defined (i.e. NOT undefined and NOT null) or not. |
"use strict"; | ||
const strings = require('./strings'); | ||
const isNotBlank = strings.isNotBlank; | ||
const trim = strings.trim; | ||
const trimOrEmpty = strings.trimOrEmpty; | ||
const stringify = strings.stringify; | ||
const isString = strings.isString; | ||
/** | ||
@@ -11,3 +18,9 @@ * Module containing a collection of standard application AppError subclasses for more commonly used error-related HTTP | ||
*/ | ||
// Error conversion functions | ||
module.exports.toAppError = toAppError; | ||
module.exports.toAppErrorForApiGateway = toAppErrorForApiGateway; | ||
module.exports.getHttpStatus = getHttpStatus; | ||
module.exports.setTypeName = setTypeName; | ||
/** A list of all of the 400-series HTTP status codes currently directly supported (and to be mapped on API Gateway). */ | ||
@@ -22,8 +35,3 @@ const supported400Codes = [400, 401, 403, 404, 408, 429]; | ||
const Strings = require('./strings'); | ||
const isNotBlank = Strings.isNotBlank; | ||
const trim = Strings.trim; | ||
const trimOrEmpty = Strings.trimOrEmpty; | ||
const stringify = Strings.stringify; | ||
const isString = Strings.isString; | ||
module.exports.supportedHttpStatusCodes = Object.freeze(supportedCodes); | ||
@@ -399,37 +407,25 @@ /** | ||
// Exports for each of the AppError "classes" and other related utility functions. | ||
module.exports.AppError = AppError; | ||
module.exports = { | ||
/** A "base class" for standard app errors, which can also be used to create a new AppError with an unsupported HTTP status code */ | ||
AppError: AppError, | ||
// 400-series | ||
module.exports.BadRequest = BadRequest; | ||
module.exports.Unauthorized = Unauthorized; | ||
module.exports.Forbidden = Forbidden; | ||
module.exports.NotFound = NotFound; | ||
module.exports.RequestTimeout = RequestTimeout; | ||
module.exports.TooManyRequests = TooManyRequests; | ||
// 400-series | ||
BadRequest: BadRequest, | ||
Unauthorized: Unauthorized, | ||
Forbidden: Forbidden, | ||
NotFound: NotFound, | ||
RequestTimeout: RequestTimeout, | ||
TooManyRequests: TooManyRequests, | ||
// 500-series | ||
module.exports.InternalServerError = InternalServerError; | ||
module.exports.BadGateway = BadGateway; | ||
module.exports.ServiceUnavailable = ServiceUnavailable; | ||
module.exports.GatewayTimeout = GatewayTimeout; | ||
// 500-series | ||
InternalServerError: InternalServerError, | ||
BadGateway: BadGateway, | ||
ServiceUnavailable: ServiceUnavailable, | ||
GatewayTimeout: GatewayTimeout, | ||
/** HTTP status codes with explicit class support and allowed to pass through to API Gateway by default */ | ||
supportedHttpStatusCodes: Object.freeze(supportedCodes), | ||
// Error conversion functions | ||
toAppError: toAppError, | ||
toAppErrorForApiGateway: toAppErrorForApiGateway, | ||
getHttpStatus: getHttpStatus, | ||
setTypeName: setTypeName | ||
}; | ||
function setTypeName(type) { | ||
const prototype = type.prototype; | ||
if (!prototype.hasOwnProperty('name')) { | ||
Object.defineProperty(prototype, 'name', {value: type.name, enumerable: false, writable: true, configurable: true}); | ||
Object.defineProperty(prototype, 'name', | ||
{value: type.name, enumerable: false, writable: true, configurable: true} | ||
); | ||
} | ||
} |
@@ -6,8 +6,6 @@ /** | ||
*/ | ||
module.exports = { | ||
distinct: distinct, | ||
isDistinct: isDistinct, | ||
isArrayOfType: isArrayOfType, | ||
flatten: flatten | ||
}; | ||
module.exports.distinct = distinct; | ||
module.exports.isDistinct = isDistinct; | ||
module.exports.isArrayOfType = isArrayOfType; | ||
module.exports.flatten = flatten; | ||
@@ -14,0 +12,0 @@ /** |
'use strict'; | ||
// inter-dependencies | ||
const strings = require('./strings'); | ||
const isString = strings.isString; | ||
/** | ||
@@ -8,19 +12,8 @@ * General utilities for encoding/decoding between Base 64 and UTF-8. | ||
*/ | ||
module.exports = { | ||
/** Attempts to convert the given data object or value into a JSON string and then encodes that to a base 64 string */ | ||
toBase64: toBase64, | ||
/** Attempts to convert the given base 64 decodable/encodable into a utf-8 encoded string and then parses that into a JSON object or value */ | ||
fromBase64: fromBase64, | ||
/** Attempts to convert the given utf-8 decodable/encodable into a base 64 encoded string */ | ||
toBase64FromUtf8: toBase64FromUtf8, | ||
/** Attempts to convert the given base 64 decodable/encodable into a utf-8 encoded string. */ | ||
toUtf8FromBase64: toUtf8FromBase64, | ||
/** Returns true if the given value is a string, Buffer or Array and hence are PROBABLY encodable/decodable. */ | ||
isEncodableDecodable: isEncodableDecodable | ||
}; | ||
module.exports.toBase64 = toBase64; | ||
module.exports.fromBase64 = fromBase64; | ||
module.exports.toBase64FromUtf8 = toBase64FromUtf8; | ||
module.exports.toUtf8FromBase64 = toUtf8FromBase64; | ||
module.exports.isEncodableDecodable = isEncodableDecodable; | ||
// inter-dependencies | ||
const strings = require('./strings'); | ||
const isString = strings.isString; | ||
/** | ||
@@ -27,0 +20,0 @@ * Attempts to convert the given data object or value into a JSON string and then encodes that to a base 64 string (if |
@@ -8,8 +8,4 @@ 'use strict'; | ||
*/ | ||
module.exports = { | ||
/** Returns true if the given value is actually a boolean or Boolean; false otherwise. */ | ||
isBoolean : isBoolean, | ||
/** Returns true if the given value actually contains true or false or is a Boolean */ | ||
isTrueOrFalse: isTrueOrFalse | ||
}; | ||
module.exports.isBoolean = isBoolean; | ||
module.exports.isTrueOrFalse = isTrueOrFalse; | ||
@@ -16,0 +12,0 @@ /** |
@@ -8,5 +8,5 @@ 'use strict'; | ||
const Strings = require('./strings'); | ||
const trim = Strings.trim; | ||
const isNotBlank = Strings.isNotBlank; | ||
const strings = require('./strings'); | ||
const trim = strings.trim; | ||
const isNotBlank = strings.isNotBlank; | ||
@@ -22,16 +22,16 @@ const hasOwnProperty = Object.prototype.hasOwnProperty; | ||
*/ | ||
module.exports = { | ||
// Public API | ||
copy: copy, | ||
copyNamedProperties: copyNamedProperties, | ||
copyDescriptor: copyDescriptor, | ||
// Internal API | ||
configureCopyContext: configureCopyContext, | ||
isCopyableObject: isCopyableObject, | ||
copyObject: copyObject, | ||
createObject: createObject, | ||
copyPropertyDescriptors: copyPropertyDescriptors, | ||
copyPropertyDescriptor: copyPropertyDescriptor | ||
}; | ||
// Public API | ||
// noinspection JSDeprecatedSymbols | ||
module.exports.copy = copy; | ||
module.exports.copyNamedProperties = copyNamedProperties; | ||
module.exports.copyDescriptor = copyDescriptor; | ||
// Internal API | ||
module.exports.configureCopyContext = configureCopyContext; | ||
module.exports.isCopyableObject = isCopyableObject; | ||
module.exports.copyObject = copyObject; | ||
module.exports.createObject = createObject; | ||
module.exports.copyPropertyDescriptors = copyPropertyDescriptors; | ||
module.exports.copyPropertyDescriptor = copyPropertyDescriptor; | ||
/** | ||
@@ -38,0 +38,0 @@ * Creates & returns a copy of the given object by copying its properties into a new object of a similar type if the |
44
dates.js
@@ -20,28 +20,26 @@ 'use strict'; | ||
*/ | ||
module.exports = { | ||
// Regular expressions | ||
simpleISODateTimeRegex: simpleISODateTimeRegex, | ||
simpleISODateRegex: simpleISODateRegex, | ||
extendedISODateTimeRegex: extendedISODateTimeRegex, | ||
extendedISODateRegex: extendedISODateRegex, | ||
// Regular expressions | ||
module.exports.simpleISODateTimeRegex = simpleISODateTimeRegex; | ||
module.exports.simpleISODateRegex = simpleISODateRegex; | ||
module.exports.extendedISODateTimeRegex = extendedISODateTimeRegex; | ||
module.exports.extendedISODateRegex = extendedISODateRegex; | ||
// Date string matching | ||
isSimpleISODateTimeLike: isSimpleISODateTimeLike, | ||
isSimpleISODateLike: isSimpleISODateLike, | ||
isExtendedISODateTimeLike: isExtendedISODateTimeLike, | ||
isExtendedISODateLike: isExtendedISODateLike, | ||
// Date string matching | ||
module.exports.isSimpleISODateTimeLike = isSimpleISODateTimeLike; | ||
module.exports.isSimpleISODateLike = isSimpleISODateLike; | ||
module.exports.isExtendedISODateTimeLike = isExtendedISODateTimeLike; | ||
module.exports.isExtendedISODateLike = isExtendedISODateLike; | ||
// Date matching | ||
isSimpleISODateTime: isSimpleISODateTime, | ||
isSimpleISODate: isSimpleISODate, | ||
isExtendedISODateTime: isExtendedISODateTime, | ||
isExtendedISODate: isExtendedISODate, | ||
// Date matching | ||
module.exports.isSimpleISODateTime = isSimpleISODateTime; | ||
module.exports.isSimpleISODate = isSimpleISODate; | ||
module.exports.isExtendedISODateTime = isExtendedISODateTime; | ||
module.exports.isExtendedISODate = isExtendedISODate; | ||
// Conversion to Date | ||
toSimpleISODateTime: toSimpleISODateTime, | ||
toSimpleISODate: toSimpleISODate, | ||
toDateTime: toDateTime, | ||
toExtendedISODate: toExtendedISODate, | ||
isValidDate: isValidDate | ||
}; | ||
// Conversion to Date | ||
module.exports.toSimpleISODateTime = toSimpleISODateTime; | ||
module.exports.toSimpleISODate = toSimpleISODate; | ||
module.exports.toDateTime = toDateTime; | ||
module.exports.toExtendedISODate = toExtendedISODate; | ||
module.exports.isValidDate = isValidDate; | ||
@@ -48,0 +46,0 @@ /** |
@@ -8,2 +8,5 @@ 'use strict'; | ||
*/ | ||
module.exports.setTypeName = setTypeName; | ||
module.exports.prefixMessage = prefixMessage; | ||
module.exports.toJSON = toJSON; | ||
@@ -29,2 +32,3 @@ /** | ||
} | ||
module.exports.FatalError = FatalError; | ||
@@ -48,2 +52,3 @@ /** | ||
} | ||
module.exports.TransientError = TransientError; | ||
@@ -67,12 +72,4 @@ /** | ||
} | ||
module.exports.TimeoutError = TimeoutError; | ||
module.exports = { | ||
FatalError: FatalError, | ||
TransientError: TransientError, | ||
TimeoutError: TimeoutError, | ||
setTypeName: setTypeName, | ||
prefixMessage: prefixMessage, | ||
toJSON: toJSON | ||
}; | ||
function prefixMessage(prefix, message) { | ||
@@ -79,0 +76,0 @@ const pfx = prefix ? prefix.toString() : ''; |
@@ -17,2 +17,3 @@ 'use strict'; | ||
// noinspection JSDeprecatedSymbols | ||
/** | ||
@@ -23,10 +24,9 @@ * Module containing a `merge` function for merging state from one object into another object. | ||
*/ | ||
module.exports = { | ||
// Public API | ||
merge: merge, | ||
// // Internal API | ||
// configureMergeContext: configureMergeContext, | ||
// mergeObject: mergeObject | ||
}; | ||
// Public API | ||
module.exports.merge = merge; | ||
// // Internal API | ||
// module.exports.configureMergeContext = configureMergeContext; | ||
// module.exports.mergeObject = mergeObject; | ||
/** | ||
@@ -33,0 +33,0 @@ * Merges the properties of the given 'from' object into the given 'to' object, only replacing same named properties in |
@@ -20,39 +20,33 @@ 'use strict'; | ||
*/ | ||
module.exports = { | ||
/** Returns true if the given value is a number; false otherwise. */ | ||
isNumber: isNumber, | ||
/** Returns true if the given value is a number and finite; false otherwise. */ | ||
isFiniteNumber: isFiniteNumber, | ||
/** Returns true if the value is Infinity, -Infinity or NaN; false otherwise. */ | ||
isSpecialNumber: isSpecialNumber, | ||
/** Returns true if the number is NaN or if it is an instance of Number and its value is NaN; false otherwise. */ | ||
isNaN: isNaN, | ||
isInteger: isInteger, | ||
isSafeInteger: isSafeInteger, | ||
toInteger: toInteger, | ||
module.exports.isNumber = isNumber; | ||
module.exports.isFiniteNumber = isFiniteNumber; | ||
module.exports.isSpecialNumber = isSpecialNumber; | ||
module.exports.isNaN = isNaN; | ||
module.exports.isInteger = isInteger; | ||
module.exports.isSafeInteger = isSafeInteger; | ||
module.exports.toInteger = toInteger; | ||
integerRegex: integerRegex, | ||
numberRegex: numberRegex, | ||
module.exports.integerRegex = integerRegex; | ||
module.exports.numberRegex = numberRegex; | ||
isNumberLike: isNumberLike, | ||
isIntegerLike: isIntegerLike, | ||
isZeroLike: isZeroLike, | ||
module.exports.isNumberLike = isNumberLike; | ||
module.exports.isIntegerLike = isIntegerLike; | ||
module.exports.isZeroLike = isZeroLike; | ||
toNumberLike: toNumberLike, | ||
module.exports.toNumberLike = toNumberLike; | ||
toDecimalLike: toDecimalLike, | ||
toDecimalLikeOrNaN: toDecimalLikeOrNaN, | ||
module.exports.toDecimalLike = toDecimalLike; | ||
module.exports.toDecimalLikeOrNaN = toDecimalLikeOrNaN; | ||
toIntegerLike: toIntegerLike, | ||
toIntegerLikeOrNaN: toIntegerLikeOrNaN, | ||
module.exports.toIntegerLike = toIntegerLike; | ||
module.exports.toIntegerLikeOrNaN = toIntegerLikeOrNaN; | ||
toNumberOrIntegerLike: toNumberOrIntegerLike, | ||
module.exports.toNumberOrIntegerLike = toNumberOrIntegerLike; | ||
removeLeadingZeroes: removeLeadingZeroes, | ||
removeTrailingZeroes: removeTrailingZeroes, | ||
zeroPadLeft: zeroPadLeft, | ||
removeSignIfZero: removeSignIfZeroLike, | ||
module.exports.removeLeadingZeroes = removeLeadingZeroes; | ||
module.exports.removeTrailingZeroes = removeTrailingZeroes; | ||
module.exports.zeroPadLeft = zeroPadLeft; | ||
module.exports.removeSignIfZero = removeSignIfZeroLike; | ||
nearlyEqual: nearlyEqual | ||
}; | ||
module.exports.nearlyEqual = nearlyEqual; | ||
@@ -325,2 +319,3 @@ /** | ||
} | ||
/** | ||
@@ -393,3 +388,3 @@ * Returns the given number string without superfluous trailing zeroes. | ||
//let m = Math.max(Math.abs(a), Math.abs(b)); | ||
let m = Math.abs(a)/2 + Math.abs(b)/2; // average magnitude, seems to work better than sum | ||
let m = Math.abs(a) / 2 + Math.abs(b) / 2; // average magnitude, seems to work better than sum | ||
// Constrain m to be within the range MIN_VALUE to MAX_VALUE to avoid divide/times by zero & +/- infinities | ||
@@ -400,2 +395,3 @@ m = Math.min(Math.max(m, Number.MIN_VALUE), Number.MAX_VALUE); | ||
} | ||
// // Algorithm translated from http://floating-point-gui.de/errors/comparison/ | ||
@@ -402,0 +398,0 @@ // function nearlyEqual_0(a, b) { |
'use strict'; | ||
const Strings = require('./strings'); | ||
const trim = Strings.trim; | ||
const isNotBlank = Strings.isNotBlank; | ||
const strings = require('./strings'); | ||
const trim = strings.trim; | ||
const isNotBlank = strings.isNotBlank; | ||
@@ -11,3 +11,2 @@ const any = require('./any'); | ||
// noinspection JSUnusedGlobalSymbols | ||
/** | ||
@@ -18,25 +17,24 @@ * Module containing utilities for working with objects. | ||
*/ | ||
module.exports = { | ||
/** @deprecated - use {@linkcode core-functions/any#valueOf} instead */ | ||
valueOf: any.valueOf, | ||
isTypedArray: isTypedArray, | ||
getPropertyNames: getPropertyNames, | ||
getPropertySymbols: getPropertySymbols, | ||
getPropertyKeys: getPropertyKeys, | ||
getPropertyDescriptors: getPropertyDescriptors, | ||
getPropertyValueByKeys: getPropertyValueByKeys, | ||
getPropertyDescriptorByKeys: getPropertyDescriptorByKeys, | ||
getPropertyValueByCompoundName: getPropertyValueByCompoundName, | ||
hasOwnPropertyWithKeys: hasOwnPropertyWithKeys, | ||
hasOwnPropertyWithCompoundName: hasOwnPropertyWithCompoundName, | ||
/** @deprecated */ | ||
copy: copy, | ||
/** @deprecated */ | ||
merge: merge, | ||
/** @deprecated */ | ||
copyNamedProperties: copyNamedProperties, | ||
toKeyValuePairs: toKeyValuePairs, | ||
getOwnPropertyNamesRecursively: getOwnPropertyNamesRecursively | ||
}; | ||
module.exports.isTypedArray = isTypedArray; | ||
module.exports.getPropertyNames = getPropertyNames; | ||
module.exports.getPropertySymbols = getPropertySymbols; | ||
module.exports.getPropertyKeys = getPropertyKeys; | ||
module.exports.getPropertyDescriptors = getPropertyDescriptors; | ||
module.exports.getPropertyValueByKeys = getPropertyValueByKeys; | ||
module.exports.getPropertyDescriptorByKeys = getPropertyDescriptorByKeys; | ||
module.exports.getPropertyValueByCompoundName = getPropertyValueByCompoundName; | ||
module.exports.hasOwnPropertyWithKeys = hasOwnPropertyWithKeys; | ||
module.exports.hasOwnPropertyWithCompoundName = hasOwnPropertyWithCompoundName; | ||
module.exports.toKeyValuePairs = toKeyValuePairs; | ||
module.exports.getOwnPropertyNamesRecursively = getOwnPropertyNamesRecursively; | ||
/** @deprecated use {@linkcode core-functions/any#valueOf} instead */ | ||
module.exports.valueOf = any.valueOf; | ||
/** @deprecated */ | ||
module.exports.copy = copy; | ||
/** @deprecated */ | ||
module.exports.copyNamedProperties = copyNamedProperties; | ||
/** @deprecated */ | ||
module.exports.merge = merge; | ||
/** | ||
@@ -46,3 +44,3 @@ * Returns true if object is a subclass instance of TypedArray; false otherwise. | ||
* @returns {boolean} true if object is a subclass instance of TypedArray; false otherwise | ||
*/ | ||
fffffffff */ | ||
function isTypedArray(object) { | ||
@@ -49,0 +47,0 @@ return object instanceof Int8Array || object instanceof Uint8Array || object instanceof Uint8ClampedArray || |
{ | ||
"name": "core-functions", | ||
"version": "3.0.11", | ||
"version": "3.0.12", | ||
"description": "Core functions, utilities and classes for working with Node/JavaScript primitives and built-in objects, including strings, booleans, Promises, base 64, Arrays, Objects, standard AppErrors, etc.", | ||
@@ -14,5 +14,5 @@ "author": "Byron du Preez", | ||
"devDependencies": { | ||
"tape": "^4.7.0" | ||
"tape": "^4.8.0" | ||
}, | ||
"repository": "https://github.com/byron-dupreez/core-functions" | ||
} |
@@ -8,3 +8,29 @@ 'use strict'; | ||
/** | ||
* Module containing Promise utility functions. | ||
* @module core-functions/promises | ||
* @author Byron du Preez | ||
*/ | ||
module.exports.isPromise = isPromise; | ||
module.exports.isPromiseLike = isPromiseLike; | ||
module.exports.toPromise = toPromise; | ||
module.exports.wrap = wrap; | ||
module.exports.try = attempt; | ||
module.exports.delay = delay; | ||
module.exports.allOrOne = allOrOne; | ||
module.exports.every = every; | ||
module.exports.one = one; | ||
module.exports.flatten = flatten; | ||
module.exports.chain = chain; | ||
module.exports.installCancel = installCancel; | ||
module.exports.installCancelTimeout = installCancelTimeout; | ||
module.exports.avoidUnhandledPromiseRejectionWarning = avoidUnhandledPromiseRejectionWarning; | ||
/** @deprecated */ | ||
module.exports.wrapMethod = wrapMethod; | ||
/** @deprecated */ | ||
module.exports.wrapNamedMethod = wrapNamedMethod; | ||
/** | ||
* An Error subclass thrown to cancel/short-circuit a promise that is waiting for a list of promises to resolve (see | ||
@@ -41,2 +67,4 @@ * {@link every}) or for a chained list of promise-returning function calls with inputs to resolve (see {@link chain}). | ||
module.exports.CancelledError = CancelledError; | ||
class DelayCancelledError extends Error { | ||
@@ -56,45 +84,3 @@ /** | ||
/** | ||
* Module containing Promise utility functions. | ||
* @module core-functions/promises | ||
* @author Byron du Preez | ||
*/ | ||
module.exports = { | ||
/** Returns true if the given value is a native Promise; otherwise false */ | ||
isPromise: isPromise, | ||
/** Returns true if the given value is a native Promise or a promise-like ("then-able") object; otherwise false */ | ||
isPromiseLike: isPromiseLike, | ||
/** Transforms the given promise-like object (or non-promise value) into a native Promise */ | ||
toPromise: toPromise, | ||
/** Returns a function that will wrap and convert a node-style function into a Promise-returning function */ | ||
wrap: wrap, | ||
/** @deprecated Use `wrap` instead - see OPTION 1 or 2 in its JDoc comments */ | ||
wrapMethod: wrapMethod, | ||
/** @deprecated Use `wrap` instead - see OPTION 1 or 2 in its JDoc comments */ | ||
wrapNamedMethod: wrapNamedMethod, | ||
/** Triggers execution of the given (typically synchronous) no-arg function, which may throw an error, within a new promise and returns the new promise */ | ||
try: attempt, | ||
/** Starts a simple timeout Promise, which will resolve after the specified delay in milliseconds */ | ||
delay: delay, | ||
/** Transforms the given result into a single Promise by applying Promise.all to the given result (if it's an Array); otherwise by applying Promise.resolve to the given non-Array result */ | ||
allOrOne: allOrOne, | ||
/** Returns a promise that will return a list of Success or Failure outcomes, each of which contains either a resolved value or a rejected error, for the given promises */ | ||
every: every, | ||
/** Maps the given promise to a native Promise of a Success or Failure outcome */ | ||
one: one, | ||
/** Recursively flattens the given value into either the given non-promise value or a single promise. */ | ||
flatten: flatten, | ||
/** Returns a promise that will return a list of Success or Failure outcomes generated by sequentially chaining calls to the given function `f` with each successive element of the given array of `elements` */ | ||
chain: chain, | ||
/** An Error subclass thrown to cancel/short-circuit a promise that is waiting for a list of promises to resolve. */ | ||
CancelledError: CancelledError, | ||
/** An Error subclass thrown to cancel a delay promise that is waiting for a timeout to complete. */ | ||
DelayCancelledError: DelayCancelledError, | ||
/** Installs the given cancel function onto the given cancellable object */ | ||
installCancel: installCancel, | ||
/** Installs the given cancelTimeout function onto the given cancellable object */ | ||
installCancelTimeout: installCancelTimeout, | ||
/** Attaches an arbitrary `catch` clause to the given promise to avoid an unneeded UnhandledPromiseRejectionWarning */ | ||
avoidUnhandledPromiseRejectionWarning: avoidUnhandledPromiseRejectionWarning | ||
}; | ||
module.exports.DelayCancelledError = DelayCancelledError; | ||
@@ -101,0 +87,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
# core-functions v3.0.11 | ||
# core-functions v3.0.12 | ||
@@ -3,0 +3,0 @@ Core functions, utilities and classes for working with Node/JavaScript primitives and built-in objects, including |
## Changes | ||
### 3.0.12 | ||
- Changed all exports to modifications of the default `module.exports` object instead of replacing the default object | ||
### 3.0.11 | ||
@@ -4,0 +7,0 @@ - Changes to `strings` module: |
@@ -11,2 +11,22 @@ 'use strict'; | ||
/** | ||
* Module containing utilities for sorting. | ||
* @module core-functions/sorting | ||
* @author Byron du Preez | ||
*/ | ||
module.exports.compareUndefinedOrNull = compareUndefinedOrNull; | ||
module.exports.compareNumbers = compareNumbers; | ||
module.exports.compareStrings = compareStrings; | ||
module.exports.compareBooleans = compareBooleans; | ||
module.exports.compareDates = compareDates; | ||
module.exports.compareIntegerLikes = compareIntegerLikes; | ||
module.exports.toSortable = toSortable; | ||
module.exports.sortSortable = sortSortable; | ||
module.exports.sortKeyValuePairsByKey = sortKeyValuePairsByKey; | ||
// Deprecated | ||
/** @deprecated - use {@linkcode core-functions/any#notDefined} instead */ | ||
module.exports.isUndefinedOrNull = any.notDefined; | ||
/** | ||
* An enum for the types of sorting currently identified & supported | ||
@@ -27,27 +47,5 @@ * @enum {string} | ||
Object.freeze(SortType); | ||
module.exports.SortType = SortType; | ||
/** | ||
* Module containing utilities for sorting. | ||
* @module core-functions/sorting | ||
* @author Byron du Preez | ||
*/ | ||
module.exports = { | ||
SortType: SortType, | ||
/** @deprecated - use {@linkcode core-functions/any#notDefined} instead */ | ||
isUndefinedOrNull: any.notDefined, | ||
compareUndefinedOrNull: compareUndefinedOrNull, | ||
compareNumbers: compareNumbers, | ||
compareStrings: compareStrings, | ||
compareBooleans: compareBooleans, | ||
compareDates: compareDates, | ||
compareIntegerLikes: compareIntegerLikes, | ||
toSortable: toSortable, | ||
sortSortable: sortSortable, | ||
sortKeyValuePairsByKey: sortKeyValuePairsByKey | ||
}; | ||
/** | ||
* Compares two undefined or null values for sorting of a useless array consisting entirely of undefined or null values. | ||
@@ -226,5 +224,5 @@ * Also used by the other compare functions to force null to the front of the sorted result. When used with Array sort, | ||
allNumbers ? SortType.NUMBER : allIntegersOrIntegerLikes ? SortType.INTEGER_LIKE : | ||
allNumbersOrNumberLike ? SortType.NUMBER : allBooleans ? SortType.BOOLEAN : | ||
allDatesOrDateLikes ? SortType.DATE : allDateTimesOrDateTimeLikes ? SortType.DATE_TIME : | ||
allStrings ? SortType.STRING : SortType.UNKNOWN; | ||
allNumbersOrNumberLike ? SortType.NUMBER : allBooleans ? SortType.BOOLEAN : | ||
allDatesOrDateLikes ? SortType.DATE : allDateTimesOrDateTimeLikes ? SortType.DATE_TIME : | ||
allStrings ? SortType.STRING : SortType.UNKNOWN; | ||
@@ -231,0 +229,0 @@ // Finally normalize mixed types of values all to the same sortable type based on the resolved sort type |
'use strict'; | ||
// noinspection JSUnusedGlobalSymbols | ||
const inspectOpts = {depth: null, breakLength: Infinity}; // unfortunately breakLength is only available in later Node versions than 4.3.2 | ||
const breakRegex = /\s*[\n\r]+\s*/g; | ||
const promiseInspectRegex = /^(Promise \{)([\s\n\r]+)(.*)([\s\n\r]+)(})$/; | ||
/** | ||
@@ -9,28 +12,14 @@ * Module containing utilities for working with strings. | ||
*/ | ||
module.exports = { | ||
/** Returns true if the given value is a string; false otherwise */ | ||
isString: isString, | ||
/** Returns true if the given string is blank (i.e. undefined, null, empty or contains only whitespace); false otherwise */ | ||
isBlank: isBlank, | ||
/** Returns true if the given string is NOT blank (i.e. NOT undefined, null, empty or contains only whitespace); false otherwise */ | ||
isNotBlank: isNotBlank, | ||
/** Trims the given value if it is a string; otherwise returns a non-string value as is */ | ||
trim: trim, | ||
/** | ||
* Alias for trim | ||
* @deprecated since 1.1.0 | ||
*/ | ||
safeTrim: trim, | ||
/** Trims the given value (if it's a string) or returns an empty string (if it's undefined or null); otherwise returns the non-undefined, non-null, non-string value as is. */ | ||
trimOrEmpty: trimOrEmpty, | ||
/** Returns the given value as a string with special case handling for various types */ | ||
stringify: stringify, | ||
nthIndexOf: nthIndexOf, | ||
toLowerCase: toLowerCase, | ||
stringifyKeyValuePairs: stringifyKeyValuePairs | ||
}; | ||
module.exports.isString = isString; | ||
module.exports.isBlank = isBlank; | ||
module.exports.isNotBlank = isNotBlank; | ||
module.exports.trim = trim; | ||
module.exports.trimOrEmpty = trimOrEmpty; | ||
module.exports.stringify = stringify; | ||
module.exports.nthIndexOf = nthIndexOf; | ||
module.exports.toLowerCase = toLowerCase; | ||
module.exports.stringifyKeyValuePairs = stringifyKeyValuePairs; | ||
const inspectOpts = {depth: null, breakLength: Infinity}; // unfortunately breakLength is only available in later Node versions than 4.3.2 | ||
const breakRegex = /\s*[\n\r]+\s*/g; | ||
const promiseInspectRegex = /^(Promise \{)([\s\n\r]+)(.*)([\s\n\r]+)(})$/; | ||
/** @deprecated since 1.1.0, use trim instead */ | ||
module.exports.safeTrim = trim; | ||
@@ -37,0 +26,0 @@ // Attempts to get Node's util.js inspect function (if available) |
@@ -10,6 +10,4 @@ 'use strict'; | ||
*/ | ||
module.exports = { | ||
cancelTimeout: cancelTimeout, | ||
cancelInterval: cancelInterval | ||
}; | ||
module.exports.cancelTimeout = cancelTimeout; | ||
module.exports.cancelInterval = cancelInterval; | ||
@@ -16,0 +14,0 @@ /** |
10
tries.js
@@ -293,2 +293,4 @@ 'use strict'; | ||
module.exports.Try = Try; | ||
/** | ||
@@ -354,2 +356,4 @@ * Synonym for {@linkcode Try.attempt} | ||
module.exports.Success = Success; | ||
/** | ||
@@ -407,6 +411,2 @@ * A Failure represents a failed execution of a function and contains the error thrown by the function | ||
module.exports = { | ||
Try: Try, | ||
Success: Success, | ||
Failure: Failure | ||
}; | ||
module.exports.Failure = Failure; |
955479
15248