Package detail

@nevware21/ts-utils

nevware211.9mMIT0.12.2

Common JavaScript/TypeScript helper functions for better minification

ts, typescript, js, javascript

readme

@nevware21/ts-utils

Common JavaScript/TypeScript helper functions for better minification

GitHub Workflow Status (main) codecov npm version downloads downloads

Description

This is a collection of general JavaScript functions (written in and for TypeScript) to aid with removing code duplication to assist with minification, the provided functions are expected to only rarely be included in their namespaced environment.

Support for standard JavaScript functions (ES5+) that are not support in all environments will be backed by internal polyfill implementations when not available.

Test Environments

  • Node (16, 18, 20, 22)
  • Browser (Chromium - headless)
  • Web Worker (Chromium - headless)

All of the polyfill functions are tested against the standard native implementations for node, browser and web-worker to ensure compatibility.

Documentation and details

See the documentation generated from source code via typedoc for a full list and details of all of the available types, functions and interfaces.

See Browser Support for details.

Type Functions / Helpers / Aliases / Polyfills
Runtime Environment Checks getCancelIdleCallback(); getDocument(); getGlobal(); getHistory(); getIdleCallback(); getInst(); getNavigator(); getPerformance(); getWindow(); hasDocument(); hasHistory(); hasNavigator(); hasPerformance(); hasWindow(); isNode(); isWebWorker(); hasIdleCallback(); lazySafeGetInst();
Type Identity isArray(); isArrayBuffer(); isBigInt(); isBlob(); isBoolean(); isDate(); isElement(); isElementLike(); isError(); isFile(); isFiniteNumber(); isFormData(); isFunction(); isInteger(); isIterable(); isIterator(); isMap(); isMapLike(); isNullOrUndefined(); isNumber(); isObject(); isPlainObject(); isPrimitive(); isPrimitiveType(); isPromise(); isPromiseLike(); isRegExp(); isSet(); isSetLike(); isStrictNullOrUndefined(); isStrictUndefined(); isString(); isThenable(); isTypeof(); isUndefined(); isWeakMap(); isWeakSet();
Value Check hasValue(); isDefined(); isNotTruthy(); isNullOrUndefined(); isStrictNullOrUndefined(); isStrictUndefined(); isTruthy(); isUndefined();
Value getValueByKey(); setValueByKey(); getValueByIter(); setValueByIter(); encodeAsJson(); encodeAsHtml(); asString(); getIntValue(); normalizeJsName();
   
Array arrAppend(); arrContains(); arrEvery(); arrFilter(); arrFind(); arrFindIndex(); arrFindLast(); arrFindLastIndex(); arrForEach(); arrFrom(); arrIncludes(); arrIndexOf(); arrLastIndexOf(); arrMap(); arrReduce(); arrSlice(); arrSome(); getLength(); isArray();
polyIsArray(); polyArrIncludes(); polyArrFind(); polyArrFindIndex(); polyArrFindLast(); polyArrFindLast(); polyArrFindLastIndex(); polyArrFrom();
ArrayLike arrContains(); arrEvery(); arrFilter(); arrFind(); arrFindIndex(); arrFindLast(); arrFindLastIndex(); arrForEach(); arrFrom(); arrIncludes(); arrIndexOf(); arrLastIndexOf(); arrMap(); arrReduce(); arrSlice(); arrSome(); getLength(); objEntries(); objValues();
DOM isElement(); isElementLike();
Enum createEnum(); createEnumKeyMap(); createEnumValueMap(); createSimpleMap(); createTypeMap();
Error createCustomError(); isError(); throwError(); throwRangeError(); throwTypeError(); throwUnsupported();
Function fnApply(); fnBind(); fnCall(); createFnDeferredProxy(); createProxyFuncs(); readArgs();
Idle getCancelIdleCallback(); getIdleCallback(); hasIdleCallback(); setDefaultIdleTimeout(); setDefaultMaxExecutionTime();
Iterator createArrayIterator(); createIterator(); createIterable(); createRangeIterator(); iterForOf(); isIterable(); isIterator(); makeIterable(); arrAppend(); arrFrom();
Number getIntValue(); isInteger(); isFiniteNumber(); isNumber();
Math mathAbs(); mathAcos(); mathAsin(); mathAtan(); mathAtan2(); mathCeil(); mathCos(); mathExp(); mathFloor(); mathLog(); mathMax(); mathMin(); mathPow(); mathRandom(); mathRound(); mathSin(); mathSqrt(); mathTan(); mathToInt(); mathTrunc();
Object deepExtend(); isObject(); objAssign(); objCopyProps(); objCreate(); objDeepCopy(); objDeepFreeze(); objDefine(); objDefineAccessors(); objDefineGet(); objDefineProp(); objDefineProps(); objDefineProperties(); objEntries(); objExtend(); objForEachKey(); objFreeze(); objFromEntries(); objGetOwnPropertyDescriptor(); objGetOwnPropertyDescriptors(); objGetOwnPropertyNames(); objGetOwnPropertySymbols(); objHasOwn(); objHasOwnProperty(); objIs(); objIsExtensible(); objIsFrozen(); objIsSealed(); objKeys(); objPreventExtensions(); objPropertyIsEnumerable(); objSeal(); objGetPrototypeOf(); objSetPrototypeOf(); objToString(); objValues();
polyObjEntries(); polyObjIs(); polyObjKeys();
String asString(); getLength(); isString(); strEndsWith(); strIndexOf(); strIsNullOrEmpty(); strIsNullOrWhiteSpace(); strLastIndexOf(); strLeft(); strPadEnd(); strPadStart(); strRepeat(); strRight(); strSlice(); strSplit(); strStartsWith(); strSubstr(); strSubstring(); strSymSplit(); strTrim(); strTrimEnd(); strTrimLeft(); strTrimRight(); strTrimStart(); strLetterCase(); strCamelCase(); strKebabCase(); strSnakeCase(); strUpper(); strLower(); strContains(); strIncludes();
polyStrSubstr(); polyStrTrim(); polyStrTrimEnd(); polyStrTrimStart(); polyStrIncludes();
Symbol WellKnownSymbols (const enum);
getKnownSymbol(); getSymbol(); hasSymbol(); isSymbol(); newSymbol(); symbolFor(); symbolKeyFor();
polyGetKnownSymbol(); polyNewSymbol(); polySymbolFor(); polySymbolKeyFor();

Polyfills are used to automatically backfill runtimes that do not support Symbol, not all of the Symbol functionality is provided.
Timer createTimeout(); createTimeoutWith(); elapsedTime(); perfNow(); utcNow(); scheduleIdleCallback(); scheduleInterval(); scheduleTimeout(); scheduleTimeoutWith(); hasIdleCallback();
For runtimes that don't support requestIdleCallback normal setTimeout() is used with the values from setDefaultIdleTimeout() and setDefaultMaxExecutionTime();
polyUtcNow();
Conversion encodeAsJson(); encodeAsHtml(); asString(); getIntValue(); normalizeJsName(); strLetterCase(); strCamelCase(); strKebabCase(); strSnakeCase(); strUpper(); strLower();
Cache createCachedValue(); createDeferredCachedValue();
Lazy getLazy(); getWritableLazy(); lazySafeGetInst(); safeGetLazy(); safeGetLazy(); setBypassLazyCache();
Safe safe(); safeGetLazy(); safeGet(); lazySafeGetInst(); safeGetWritableLazy();
Diagnostic dumpObj();
RegEx createFilenameRegex(); createWildcardRegex(); makeGlobRegex();

Unless otherwise stated in the functions documentation polyfills are used to automatically backfill unsupported functions in older ES5 runtimes

Language ECMAScript Support

ES5

This library plans to maintain ES5 compatibility for all versions of v0.x and v1.x releases

ES(future [6 next, etc])

Future versions of this library starting at version 2.x are planned to lift and remove the internal polyfills to support the new targetted baseline once it is defined. ie. It may or may not be ES2020 depending on the runtime landscape and requests received.

When we release v2.x the supported browser matrix will also shift as required to match the defined language level supported at that time.

TypeScript Support

This library is built using TypeScript v4.9.5 and uses some keywords that where added in v2.8, so while it is recommended that you use at least v4.9.5, but the definitions will require at least v2.8 and therefore this will be the current minimum support version. If there are issues with any versions of TypeScript please open an issue and we will review whether its possible to work around any limitations with any specific features.

Quickstart

Install the npm packare: npm install @nevware21/ts-utils --save

It is suggested / recommended that you use the following definition in your package.json so that you are compatible with any future releases as they become available we do not intend to make ANY known breaking changes moving forward until v2.x

"@nevware21/ts-utils": ">= 0.12.2 < 2.x"

And then just import the helpers and use them.

Simple Example

These are simple representations of using some of the basic function vs the standard provided JavaScript versions. Examples are also being included in the source and generated typedoc documentation.

Using Helpers

import { isArray, arrForEach, objForEachKey, objHasOwnProperty } from "@nevware21/ts-utils";

export function simpleTest(theValue: any): string[] {
    let result: any[] = [];

    if (isArray(theValue)) {
        arrForEach(theValue, (value, idx) => {
            if (objHasOwnProperty(theValue, value)) {
                result.push(idx + ":" + value);
            }
        });
    } else {
        objForEachKey(theValue, (key, value) => {
            if (value) {
                result.push(key + "=" + value);
            }
        });
    }

    return result;
}

Or checking if a variable is a string


import { isString } from "@nevware21/ts-utils";

function checkString(value: any) {
    let ug = 1;

    return isString(value);
}

Using standard JS functions

export function simpleTest2(theValue: any): string[] {
    let result: any[] = [];

    if (Array.isArray(theValue)) {
        for (let idx = 0; idx < theValue.length; idx++) {
            if (idx in theValue) {
                let value = theValue[idx];
                if (theValue.hasOwnProperty(value)) {
                    result.push(idx + ":" + value);
                }
            }
        }
    } else {
        Object.keys(theValue).forEach((key) => {
            let value = theValue[key];
            if (value) {
                result.push(key + "=" + value);
            }
        });
    }

    return result;
}

Just from use the helpers you can visually see that the code you write is visually simpler and it removes the need for some standard biolerplate code that you should use when iterating over objects.

But if we have a look at what the minified version might look like the difference becomes even more obvious, as while the helper function names can be minified (because they are not global and they are not namespaced against any object) while the standard public classes and their any functions cannot (normally) be minified. (There are tricks you can do in your own code but it can become messy, this library actually uses those techniques internally to aid with minification).

Minified Using Helpers (~160 bytes) but not including the actual helpers

function simpleTest(t){var r=[];if (a(t)) {f(t,function(v, i){if (h(t,v)) {r.push(i+":"+v);}});}else{e(t,function(k,v){if(v){r.push(k+"="+v);}});}return r;}

Minified Without helpers (~240 bytes)

function simpleTest2(t){var r=[];if(Array.isArray(t)){for(var i=0;i<t.length;i++){if(i in t){var v=t[i];if(t.hasOwnProperty(v)){r.push(i+":"+v);}}}}else{Object.keys(t).forEach(function(k){var v=t[k];if(v){r.push(k+"="+v);}});}return r;}

While there are obvious savings here (~80 bytes), for this derrived simple case once you add the helper implementations back to the simpleTest instance (about 240 bytes the 4 used functions) then you would be better off just using the normal functions as you would still be using 160 bytes less.

For any real world code though you will find that the normal JS functions are repeated a lot and that is when the savings kick in. Lets just take these 2 sinple examples and assume some very simple duplication of the same code.

Instances Real functions
Total = count * 240 bytes
Using Helpers
Total = (count * 160) + 240 bytes
assuming 240 bytes are only required once as the helpers don't need to be duplicated
Delta
1 240 400 -160 bytes
2 480 560 -80 bytes
3 720 720 0 bytes (break even)
4 960 880 80 bytes
5 1200 1040 160 bytes
10 2400 1840 560 bytes

In practice the savings are not so easily calculated as it really does depend on which functions you are using, how many times and the "length" of the function name and how you call the function. For example in the above this calls theValue.hasOwnProperty(value) which assumes that the any value passed is always an object and therefore has this function available, while the helper actually always calls Object.prototype.hasOwnProperty.call(theValue,value), so it will always call the object instance and if you do this in your code suddenly you have 37 bytes of uncompressable code vs 15 (for just hasOwnProperty), while when you always use the helper each usage generally becomes a single byte h(theValue).

What does this mean? Generally, that you savings will vary, but you should find that by using these utility functions instead of the standard JavaScript versions (when available) you code will be smaller.

Could you do all of this yourself and create your own "helper" function -- Yes. In fact before publishing this set of utilities that is exactly what we did in every project, mostly just copying from the previous project. And whenever we "fixed" a bug or updated the functionality guess what happened... Update nightmare finding all of the instances in every project.

Import/Export Options

This library supports multiple module formats to accommodate different project setups:

  1. ES Modules (ESM) - For modern applications using ES modules

    import { isArray, objDeepCopy } from "@nevware21/ts-utils";
  2. CommonJS - For Node.js applications

    const { isArray, objDeepCopy } = require("@nevware21/ts-utils");
  3. UMD (Universal Module Definition) - For environments that support neither ESM nor CommonJS

    <script src="node_modules/@nevware21/ts-utils/bundle/ts-utils.min.js"></script>
    <script>
      // Access via global namespace
      const isArray = nevware21.tsUtils.isArray;
    </script>

Tree Shaking

The library is designed to be tree-shakable when used with bundlers that support it (like Webpack, Rollup, or esbuild). This means that only the functions you actually import and use will be included in your final bundle, helping to keep your application size small.

// Only these specific functions will be included in your bundle
import { isString, strTrim } from "@nevware21/ts-utils";

// The rest of the library's code will be excluded by tree shaking

Advanced Usage Examples

Custom Deep Copy Handlers

The deep copy functionality (objDeepCopy and objCopyProps) supports custom handlers to control how specific object types are copied. This is especially useful for handling complex objects like class instances or special native objects.

import { 
  objDeepCopy, 
  IObjDeepCopyHandlerDetails, 
  isDate, 
  isMap, 
  isSet 
} from "@nevware21/ts-utils";

// Example class
class Person {
  constructor(public name: string, public age: number) {}

  greet() {
    return `Hello, my name is ${this.name}`;
  }
}

// Create custom handler
function customDeepCopyHandler(details: IObjDeepCopyHandlerDetails): boolean {
  const value = details.value;

  // Handle Person class instances
  if (value instanceof Person) {
    // Create a new instance with the same properties
    details.result = new Person(value.name, value.age);
    return true;
  }

  // Handle Map objects
  if (isMap(value)) {
    const newMap = new Map();
    details.result = newMap;

    // Deep copy each entry in the map
    value.forEach((val, key) => {
      // Use the details.copy method to handle recursive objects
      newMap.set(details.copy(key), details.copy(val));
    });
    return true;
  }

  // Handle Set objects
  if (isSet(value)) {
    const newSet = new Set();
    details.result = newSet;

    value.forEach(val => {
      newSet.add(details.copy(val));
    });
    return true;
  }

  // Let the library handle other types
  return false;
}

// Use the custom handler
const original = {
  person: new Person("Alice", 30),
  dates: [new Date(), new Date(2020, 0, 1)],
  preferences: new Map([
    ["theme", "dark"],
    ["fontSize", 16]
  ]),
  tags: new Set(["typescript", "javascript", "utils"])
};

const copy = objDeepCopy(original, customDeepCopyHandler);

// The copy will have new instances of Person, Map and Set
console.log(copy.person.greet()); // "Hello, my name is Alice"
console.log(copy.person !== original.person); // true - different instances
console.log(copy.preferences !== original.preferences); // true
console.log(copy.tags !== original.tags); // true

This example demonstrates how to handle:

  1. Custom class instances
  2. Built-in objects like Map and Set
  3. Maintaining object identity in recursive structures

Browser Support

General support is currently set to ES5 supported runtimes and higher.

Internal polyfills are used to backfill ES5 functionality which is not provided by older browsers.

Chrome Firefox IE Opera Safari
Latest ✔ Latest ✔
9+ ✔
Latest ✔ Latest ✔

Internet Explorer support will be dropped in v2.x

Polyfills

All of the included polyfills are tested against the current native implementation running in node, browser and worker environments to ensure that they conform to the current specification, these polyfills are only internally used for ES5 compatibility and when running in an environment (mostly IE) that does not support the required function.

Some additional polyfills are provided for simple backward compatability to enable the utility functions in older environments (such as ES3 / IE8), however, you don't have to use or include these provided polyfils. If you need to use them you will need to import the pre-packaged "polyfill" bundle (bundle/ts-polyfills-utils.min.js) directly by hosting it on your own CDN or all of the non-internal polyfill implementations are exported so you could implement your own version of the polyfill initializer or more simply provide your own alternatives.

Notes:

  • While some polyfills are provided to "somewhat" support ES3/IE8 this library does not intend to become a fully fledged polyfill library. And the polyfills provided (or contributed) are just the minimum set that have been required over time. And should be less necessary are time moves forward.
  • Several functions use the Object.defineProperty and therefore support is limited to runtimes or good polyfills that can correctly implement this functionality. (eg. createIterator; createIterable)

Contributing

Read our contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes.

changelog

v0.12.2 Apr 17th, 2025

Changelog

Issues

  • #403 [Bug] Excessive increase in 0.12.0/0.12.1 which introduced a polyfill for objGetOwnPropertyDescriptor
  • #405 [Bug] createWildcardRegex has an invalid regular expression

Tasks

  • (Partial) #401 [Task] Add pre-release testing validation with external projects
    • Adds a simple check that validates that all of the links in the readme map to the typedoc generated docs, this should catch unexpected dropped exports

Commits

  • #402 [Bug] createWildcardRegex invalid regular expression #405 and link checker #401
  • #406 [Bug] Excessive increase in 0.12.0/0.12.1 which introduced a polyfill for objGetOwnPropertyDescriptor #403

v0.12.1 Apr 14th, 2025

Changelog

Issues

  • #398 [Bug] setValueByKey function is no longer exported in version 0.12.0

Commits

  • #399 Reinstate the dropped exports due to code re-organization

v0.12.0 Apr 14th, 2025

Changelog

Issues

  • #387 [Bug] Polyfill symbol doesn't work as expected as unique key for an object
  • #389 [Bug] objCreate doesn't support additional optional properties argument
  • #392 [Bug] mathMax is defined to use using Math.min

Commits

  • #378 Bump mocha from 10.8.2 to 11.2.0
  • #383 Add objIs and polyObjIs
  • #384 Add additional Object alias functions
    • objPropertyIsEnumerable, objFromEntries, objGetOwnPropertyDescriptors,objGetOwnPropertyNames, objGetOwnPropertySymbols, objIsFrozen, objIsSealed, objPreventExtensions, objIsExtensible
    • Add new type check functions
      • isMap, isMapLike
    • Update symbol polyfill to enable isSymbol
  • #390 Fixup exports and readme for new functions
  • #391 Bump to typedoc ^0.28.2, Bump to typescript ~5.2.2
    • Use github theme
    • tag alias constants as functions
    • Bump to typescript ~5.2.2
      • remove suppressImplicitAnyIndexErrors
  • #393 [Bug] mathMax is defined to use using Math.min #392
    • Add additional ES5 Math aliases
      • mathAbs, mathExp, mathLog, mathAsin, mathAcos, mathAtan, mathAtan2, mathPow, mathSqrt, mathRandom, mathSin, mathCos, mathTan
  • #394 Add isSet, SetLike, WeakSet and isWeakMap helpers
  • #395 Add isBigInt, isElement, isEmpty, isInteger, isFiniteNumber
  • #396 Add isElementLike helper

v0.11.7 Feb 24th, 2025

Changelog

  • #369 Bump ts-mocha from 10.1.0 to 11.1.0
  • #370 Add mathRound alias for Math.round

v0.11.7 Feb 17th, 2025

Changelog

  • #366 [Bug] getWritableLazy() intriduced in 0.9.4 has not been exported
  • #353 Bump @rollup/plugin-node-resolve from 15.3.1 to 16.0.0
  • #355 Bump puppeteer from 23.11.1 to 24.0.0
  • #356 Bump glob from 11.0.0 to 11.0.1

v0.11.6 Dec 12th, 2024

Changelog

  • #337 Update dependabot.yml
  • #338 Bump github/codeql-action from 2 to 3
  • #340 Bump actions/checkout from 2 to 4
  • #339 Bump codecov/codecov-action from 2 to 4
  • #341 Bump actions/configure-pages from 4 to 5
  • #342 Bump actions/setup-node from 3 to 4
  • #343 Update to use ts-build-tools
    • #344 Bump @nevware21/ts-build-tools to ^0.1.3
  • #345 Bump codecov/codecov-action from 4 to 5
  • #347 Create FUNDING.yml
    • #348 Update FUNDING.yml
  • #350 [doc] TSDoc Error During Build

v0.11.5 Oct 23rd, 2024

Changelog

  • #324 [Doc] Auto deploy docs and remove from repo
  • #325 chore: Auto deploy docs
  • #326 Update auto-docs generation
  • #328 Bump @rollup/plugin-typescript from 11.1.6 to 12.1.0
  • #327 Typedoc: rename workflow
  • #330 Bump @rollup/plugin-commonjs from 26.0.3 to 28.0.0
  • #331 Bump puppeteer from 22.15.0 to 23.4.0
  • #333 [Bug] Glob is missing from the dev dependencies -- unable to build a clean repo
  • #332 [BUG] Sourcemap load errors in debugger from @nevware21 dependencies

v0.11.4 Sept 21st, 2024

Changelog

  • #289 Bump @typescript-eslint/parser from 6.21.0 to 7.14.1
  • #292 Bump @nevware21/grunt-eslint-ts from 0.2.4 to 0.2.5
  • #291 Bump @nevware21/grunt-ts-plugin from 0.4.5 to 0.4.6
  • #300 [Bug] The createRangeIterator() function is getting mis-optimized for a worker on chrome. #298
    • Bump @nevware21/grunt-eslint-ts from 0.2.5 to 0.5.0
    • Bump @nevware21/grunt-ts-plugin from 0.4.5 to 0.5.0
  • #302 [Bug] getInst() function is getting mis-optimized for a worker with rollup #303
    • Bump @nevware21/grunt-eslint-ts from 0.5.0 to ^0.5.1
    • Bump @nevware21/grunt-ts-plugin from 0.5.0 to ^0.5.1
  • #306 [Bug] CI Tests are failing #319
  • #318 Bump puppeteer from 22.15.0 to 23.4.0
  • #320 bug: update objDefine to use strict undefined
  • #322 Revert "Bump puppeteer from 22.15.0 to 23.4.0 (#318)"

v0.11.3 Jun 26th, 2024

Changelog

  • 286 [Feature] Don't use objDeepFreeze for enums

  • 285 Update Copyright message to conform with LLC operating agreement

  • 278 Bump @rollup/plugin-commonjs from 25.0.8 to 26.0.1

  • 288 Bump typedoc from 0.25.13 to 0.26.2

  • 279 Bump nyc from 15.1.0 to 17.0.0

v0.11.2 Apr 16th, 2024

Changelog

  • 263 Generate single unified es module for exports

v0.11.1 Mar 31st, 2024

Changelog

  • 258 Remove exports defintion from package.json

v0.11.0 Mar 18th, 2024

Changelog

  • 252 [Bug] TypeError: Illegal invocation when calling setTimeout

  • 246 [Bug] Package sizes are too large

  • 241 Remove removed function link from readme

  • 244 Fix CreateIteratorContext n documentation

v0.10.5 Feb 6th, 2024

Minification and minor performance improvements, adds createcacheValue, safe implementations.

Changelog

  • 239 Stop using internal functions for diagnostic to help with base minification for smaller usages

  • 238 Bump puppeteer from 21.11.0 to 22.0.0

v0.10.4 Jan 10th, 2024

Changelog

  • 230 [Bug] Tree-Shaking is not working properly

    • Tags additional (everything else) functions as NO_SIDE_EFFECTS so that rollup (and webpack) can tree-shake
    • Explicitly did not include all functions like isXXXX (specifically isNode) as this was causing the main entry-points for @nevware21/ts-async to drop the node support code (as it's defined as a browser package) resulting in it not supporting all environments as desired with a single package.

v0.10.3 Jan 7th, 2024

Changelog

  • 230 [Bug] Tree-Shaking is not working properly

  • 226 [Feature] Add size tests

v0.10.2 Jan 4th, 2024

Changelog

  • 211 Update signature of getInst and lazySafeGetInst to support any PropertyKey type

  • 228 Minor Performance updates

Dependencies

  • 212 Bump typedoc from 0.24.8 to 0.25.0

  • 218 Bump rollup-plugin-istanbul from 4.0.0 to 5.0.0 #218

  • 220 Fix issue with node version in ci.yml

  • 217 Bump rollup from 3.29.4 to 4.1.4

  • 223 Bump @types/sinon from 10.0.20 to 17.0.1

v0.10.1 Aug 18th, 2023

This is a critical bug fix if you are using symbolKeyFor and/or symbolFor, as the current implementations will always return a new polyfill version rather than using the native Symbol.keyFor and Symbol.for methods

Changelog

  • 208 [Bug] symbolFor and symbolKeyFor are not caching / returning the underlying instance

v0.10.0 Aug 17th, 2023

Changelog

  • 204 [Bug] Remove typescript as a peer dependency

  • 206 Update enum type definitions to provide better validation and auto code completion

  • 202 Bump @typescript-eslint/eslint-plugin from 5.62.0 to 6.1.0

  • 203 Bump puppeteer from 19.11.1 to 21.0.0

v0.9.8 June 18th, 2023

Changelog

  • 192 [Bug] iterForOf does not always process elements correctly

  • 193 [Bug] Calling return or throw on an iterator does not mark it as done

  • 194 [Bug] iterForOf swallows errors caused during the iteration

  • 196 [Feature] Add aliases for functions apply, bind and call

  • 197 [Feature] Add function proxies

v0.9.7 June 11th, 2023

Changelog

  • 185 [Feature] Add Object.entries and Array.from alias / implementations

  • 187 [Feature] Add Object.values alias / implementation

  • 189 [Feature] Update issue templates

v0.9.6 May 31st, 2023

Changelog

  • 178 [Bug] objDeepCopy creates copies of classes by default

  • 181 [Bug] customError definition is not correct, it's a mixture of constructor and implmentation

  • 182 [Feature] Allow creation of sub-class custom errors

    • Set stack trace to the top-most error class

v0.9.5 Apr 25th, 2023

Changelog

  • 173 Support: expose the internal safe helpers to allow reuse.

  • 172 Update publishing scripts

  • 171 Update publishing scripts

  • 170 Bump typedoc to ^0.24.4

v0.9.4 Mar 25th, 2023

Changelog

  • 166 Add writable Lazy support and lazy option to objDefine

    • getWritableLazy()
    • objDefine(target, "name", { l: ILazyValue });

v0.9.3 Mar 25th, 2023

Changelog

  • 164 Add arrSlice and replace _extractArgs usages

v0.9.2 Mar 24th, 2023

Changelog

  • 162 Update Lazy implementation to reduce required for getGlobal()

v0.9.1 Mar 23rd, 2023

Changelog

  • 158 Migrate get/set value by key and strSplit

  • 159 [Packaging] The single module file is causing some packagere issues

v0.9.0 Mar 15th, 2023

Changelog

  • 153 chore: Migrate encoding and conversion functions

    • strLetterCase(); strCamelCase(); strKebabCase(); strSnakeCase(); strUpper(); strLower();
    • encodeAsJson(); encodeAsHtml(); normalizeJsName();
  • 154 Minor enhancements for perf and minification and additional examples

  • 155 Add strIncludes, strContains

    • strContains(); strIncludes();

v0.8.1 Mar 2nd, 2023

Changelog

  • 148 (Priotity 1) [Bug] Creating more than 1 createCustomError() overwrites the "name" of the error.

    • Issue was causing the Error class name to be reassigned to the last created Custom Error, if no custom error was created (including the UnsupportedError) then the Error class was unaffected
  • 146 [Feature] Add an enabled / running flag to the timers to enable checking current state

v0.8.0 Feb 21st, 2023

Changelog

  • 143 Add additional Array functions and update to support ArrayLike objects

    • new Functions: arrEvery, arrFilter, arrFind, arrFindIndex, arrFindLast, arrFindLastIndex, arrIncludes, arrContains, arrLastIndexOf, arrSome
    • Updated examples and added tests for Array like
    • some polyfill versions also added

v0.7.3 Feb 17th, 2023

Changelog

  • 141 Update packaging to create single rollup resources

    • Create single module export
    • Include comments in the d.ts

v0.7.2 Feb 5th, 2023

Changelog

  • 139 Apply additional minification for enum, dumpObj, timers

v0.7.1 Feb 4th, 2023

Changelog

  • 134 Update build link

  • 135 Update to use root LICENSE and README.md in the npm published package

  • 136 chore: Update coverage reporting to include worker test run

  • 138 Add .npmignore for release

v0.7.0 Jan 12th, 2023

Changelog

  • 124 [Request] Add/expose additional NodeJS.Timer functions to the timer implementations

  • 132 Add "esnext" (es6) to package.json and available pre-bundle packages

  • 121 Bump sinon from 14.0.2 to 15.0.0

  • 123 Bump karma-spec-reporter from 0.0.34 to 0.0.35

  • 125 Bump karma-spec-reporter from 0.0.35 to 0.0.36

  • 127 Bump @rollup/plugin-json from 5.0.2 to 6.0.0

  • 126 Bump @rollup/plugin-commonjs from 23.0.7 to 24.0.0

  • 130 Bump @rollup/plugin-typescript from 10.0.1 to 11.0.0

v0.6.0 Nov 28th, 2022

Changelog

  • 115 Add optional enumerable argument to objDefineGet and objDefineAccessors

  • 116 Bump rollup from 2.79.1 to 3.3.0

  • 117 Add objDefine, objDefineProperties and objDefineProps

  • 118 Update package.json and docs for release

v0.5.0 Oct 18th, 2022

Changelog

  • 110 [Test Hook] Need the ability to clear the new lazy cache values for environment values

    • Introduces the ability to cause lazy implmentations to bypass cached values
    • Moved the location of the polyfill global symbol registry

v0.4.6 Oct 15th, 2022

Changelog

  • 106 v0.4.5 has Circular dependencies

v0.4.5 Oct 14th, 2022

Changelog

  • 99 [Bug] Fix issue where Arrays with non-indexed values are not copied

  • 100 Add lazy initialization of globals to provide better tree-shaking when not used.

  • 101 Add clearTimeout override option for the scheduleTimeoutWith

v0.4.4 Oct 10th, 2022

Changelog

  • 83 [Typing] arrForEach - the signature for the callback is incorrect

  • 84 [Bug] objDeepCopy incorrectly tries to copy classes (like Date)

    • 87 [Bug] objDeepCopy incorrectly tries to copy classes (like Date) #84

    • 90 [Bug] objDeepCopy incorrectly tries to copy classes (like Date) #84

  • 88 Add timer support

v0.4.3 Sept 9th, 2022

Changelog

  • 79 [Bug] objForEachKey() is not iterating over defined properties which are enumerable

  • 80 [Bug] toString() added in 0.4.2 is not exported from the main module

v0.4.2 Aug 15th, 2022

Changelog

  • 72 Add mathMin and mathMax

    • Add strSubstring; strSubstr; strLeft; strRight
    • Add getLength
  • 73 Add iterator and iterable creation and processing functions

    • Add creatorIterator
    • Add createArrayIterator
    • Add createIterator; createIterable; makeIterable
    • Add iterForOf
    • Add createRangeIterator
    • Update copyright notices on tests
    • Update ReadMe
  • 74 Update typedoc groups and readme

v0.4.1 Aug 12th, 2022

Changelog

  • 69 [Bug] isObject() throws a TypeError when an object is created via Object.create(null)

v0.4.0 Aug 10th, 2022

Changelog

  • 66 [Bug] strStartsWith and strEndsWith are converting all arguments to strings even if they are not

  • 67 Add isIterator() and isIterable()

    • Break out array functions into separate files
    • Update string stubs to use generated function

v0.3.4 Aug 8th, 2022

Changelog

  • 61 [Compatibilty] ReactNative uses a JavaScript Core that does not support regex lookbehinds

  • 62 [Bug] The generic definition of the arrReduce does not handle different arguments correctly

v0.3.3 Aug 5th, 2022

Changelog

  • 55 Add generic typing's to some functions

  • 56 Move source folder from ts-utils to lib and upgrade typedoc

  • 57 Bump puppeteer from 15.5.0 to 16.0.0

  • 58 Add arrMap and update typedoc groupings

v0.3.2 Aug 3rd, 2022

Changelog

  • [Bug] String trim functions are not exported #51

    • Added missing exports for
      • strEndsWith
      • strPadEnd
      • strPadStart
      • strRepeat
      • strSlice
      • strTrim
      • strTrimEnd
      • strTrimStart
      • strTrimLeft
      • strTrimRight
  • Added functions

    • arrIndexOf
    • arrReduce
    • strIndexOf
    • strLastIndexOf
  • 53 [Bug] The build generated polyfill bundle is missing from the npm package

v0.3.1 Jul, 27th, 2022

Changelog

  • 45 [TreeShaking Issue] The createCustomError is always getting included in the output.

  • 46 [Symbol support] Have the ability to always return the polyfill symbols if not supported

v0.3.0 Jul, 25th, 2022

Changelog

  • 32 Bump @types/estree from 0.0.52 to 1.0.0

  • 34 Add more Object.create and objSetPrototypeOf tests

    • Add symbol support
    • Rollup back typedoc version so descriptions are published (there is an issue with isArray and isArrayBuffer)
    • Switch to HTML Docs
  • 42 Add enum helpers and update symbol support

    • Update Custom Error to support custom error types (not just messages)
    • Add some more examples

Documentation Updates

  • 35 Update HTML link to preview

  • 36 Update to use github pages link

  • 37 Restore Old documentation references for npm

  • 40 Update readme path

  • 41 Remove old pages folder

v0.2.0 Jun 29th, 2022

Changelog

  • 26 Add Object.create and objSetPrototypeOf tests

    • Rollup back typedoc version so descriptions are published
  • 23 Add initial math, additional string and throwRangeError

    • Add math floor, ceil, trunc and toInt
    • Add string, pad, slice and trim, rework string file layout
    • Add throwRangeError
  • 25 Bump @types/estree from 0.0.51 to 0.0.52

  • 24 Bump typedoc from 0.22.18 to 0.23.1

  • 22 Bump puppeteer from 14.4.1 to 15.0.2

  • 20 Add more tests, add additional string, object helpers and custom error support

    • Split out extend
    • Split out object to avoid circular dependencies
    • Remove partial ES3 compatibility from objDefine functions
    • Add string startsWith and endsWith (with polyfills for IE)
    • Add throwUnsupportedError and createCustomError
    • Increase test coverage
  • 19 Add string and object tests -- fixing issues

    • Add combined (merge) coverage report and summary
  • 18 Add Security policy and fix a few copyright header comments

  • 17 Add web worker tests

    • Add more tests coverage
    • Fix identified issues
  • 16 Add Local browser based debugging option

  • 15 Add additional tests and browser coverage

  • 13 Update Documentation

    • Rework some base functions for better minification
    • Update the polyfill bundle to include more used functions
  • 14 Bump mocha from 9.2.2 to 10.0.0

  • 12 Add Tests and Coverage, remove rush usage

  • 10 Bump @nevware21/grunt-ts-plugin from 0.4.3 to 0.4.5

  • 11 Bump @nevware21/grunt-eslint-ts from 0.2.2 to 0.2.4

v0.1.1 May 30th, 2022

Changelog

  • [Bug] v0.1.0 has an invalid entry point defined in the package.json #5