package/LICENSE000644 0000001405 3560116604 010265 0ustar00000000 000000 ISC License Copyright (c) 2011-2022, Mariusz Nowak, @medikoo, medikoo.com Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. package/string_/camel-to-hyphen.js000644 0000001463 3560116604 014261 0ustar00000000 000000 "use strict"; var ensureString = require("type/string/ensure") , objHasOwnProperty = Object.prototype.hasOwnProperty; var capitalLetters = { A: true, B: true, C: true, D: true, E: true, F: true, G: true, H: true, I: true, J: true, K: true, L: true, M: true, N: true, O: true, P: true, Q: true, R: true, S: true, T: true, U: true, V: true, W: true, X: true, Y: true, Z: true }; module.exports = function () { var input = ensureString(this); if (!input) return input; var outputLetters = []; for (var index = 0, letter; (letter = input[index]); ++index) { if (objHasOwnProperty.call(capitalLetters, letter)) { if (index) outputLetters.push("-"); outputLetters.push(letter.toLowerCase()); } else { outputLetters.push(letter); } } return outputLetters.join(""); }; package/string_/capitalize.js000644 0000000330 3560116604 013404 0ustar00000000 000000 "use strict"; var ensureString = require("type/string/ensure"); module.exports = function () { var input = ensureString(this); if (!input) return input; return input.charAt(0).toUpperCase() + input.slice(1); }; package/math/ceil-10.js000644 0000000122 3560116604 011674 0ustar00000000 000000 "use strict"; module.exports = require("../lib/private/decimal-adjust")("ceil"); package/object/clear.js000644 0000000605 3560116604 012153 0ustar00000000 000000 "use strict"; var ensureObject = require("type/object/ensure") , ensure = require("type/ensure"); var objPropertyIsEnumerable = Object.prototype.propertyIsEnumerable; module.exports = function (object) { ensure(["object", object, ensureObject]); for (var key in object) { if (!objPropertyIsEnumerable.call(object, key)) continue; delete object[key]; } return object; }; package/lib/private/decimal-adjust.js000644 0000001437 3560116604 014731 0ustar00000000 000000 // Credit: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round // #Decimal_rounding "use strict"; var isValue = require("type/object/is") , ensureInteger = require("type/integer/ensure"); var split = String.prototype.split; module.exports = function (type) { return function (value/*, exp*/) { value = Number(value); var exp = arguments[1]; if (isValue(exp)) exp = ensureInteger(exp); if (!value) return value; if (!exp) return Math[type](value); if (!isFinite(value)) return value; // Shift var tokens = split.call(value, "e"); value = Math[type](tokens[0] + "e" + ((tokens[1] || 0) - exp)); // Shift back tokens = value.toString().split("e"); return Number(tokens[0] + "e" + (Number(tokens[1] || 0) + exp)); }; }; package/lib/private/define-function-length.js000644 0000002761 3560116604 016400 0ustar00000000 000000 "use strict"; var test = function (arg1, arg2) { return arg2; }; try { Object.defineProperty(test, "length", { configurable: true, writable: false, enumerable: false, value: 1 }); } catch (ignore) {} if (test.length === 1) { // ES2015+ var desc = { configurable: true, writable: false, enumerable: false }; module.exports = function (length, fn) { if (fn.length === length) return fn; desc.value = length; return Object.defineProperty(fn, "length", desc); }; return; } module.exports = function (length, fn) { if (fn.length === length) return fn; switch (length) { case 0: return function () { return fn.apply(this, arguments); }; case 1: return function (ignored1) { return fn.apply(this, arguments); }; case 2: return function (ignored1, ignored2) { return fn.apply(this, arguments); }; case 3: return function (ignored1, ignored2, ignored3) { return fn.apply(this, arguments); }; case 4: return function (ignored1, ignored2, ignored3, ignored4) { return fn.apply(this, arguments); }; case 5: return function (ignored1, ignored2, ignored3, ignored4, ignored5) { return fn.apply(this, arguments); }; case 6: return function (ignored1, ignored2, ignored3, ignored4, ignored5, ignored6) { return fn.apply(this, arguments); }; case 7: return function (ignored1, ignored2, ignored3, ignored4, ignored5, ignored6, ignored7) { return fn.apply(this, arguments); }; default: throw new Error("Usupported function length"); } }; package/thenable_/finally.js000644 0000001241 3560116604 013173 0ustar00000000 000000 "use strict"; var ensurePlainFunction = require("type/plain-function/ensure") , isThenable = require("type/thenable/is") , ensureThenable = require("type/thenable/ensure"); var resolveCallback = function (callback, next) { var callbackResult = callback(); if (!isThenable(callbackResult)) return next(); return callbackResult.then(next); }; module.exports = function (callback) { ensureThenable(this); ensurePlainFunction(callback); return this.then( function (result) { return resolveCallback(callback, function () { return result; }); }, function (error) { return resolveCallback(callback, function () { throw error; }); } ); }; package/math/floor-10.js000644 0000000123 3560116604 012102 0ustar00000000 000000 "use strict"; module.exports = require("../lib/private/decimal-adjust")("floor"); package/function/identity.js000644 0000000104 3560116604 013267 0ustar00000000 000000 "use strict"; module.exports = function (value) { return value; }; package/object/entries/implement.js000644 0000000312 3560116604 014523 0ustar00000000 000000 "use strict"; if (!require("./is-implemented")()) { Object.defineProperty(Object, "entries", { value: require("./implementation"), configurable: true, enumerable: false, writable: true }); } package/global-this/implementation.js000644 0000002001 3560116604 015041 0ustar00000000 000000 var naiveFallback = function () { if (typeof self === "object" && self) return self; if (typeof window === "object" && window) return window; throw new Error("Unable to resolve global `this`"); }; module.exports = (function () { if (this) return this; // Unexpected strict mode (may happen if e.g. bundled into ESM module) // Thanks @mathiasbynens -> https://mathiasbynens.be/notes/globalthis // In all ES5+ engines global object inherits from Object.prototype // (if you approached one that doesn't please report) try { Object.defineProperty(Object.prototype, "__global__", { get: function () { return this; }, configurable: true }); } catch (error) { // Unfortunate case of Object.prototype being sealed (via preventExtensions, seal or freeze) return naiveFallback(); } try { // Safari case (window.__global__ is resolved with global context, but __global__ does not) if (!__global__) return naiveFallback(); return __global__; } finally { delete Object.prototype.__global__; } })(); package/object/entries/implementation.js000644 0000000564 3560116604 015567 0ustar00000000 000000 "use strict"; var ensureValue = require("type/value/ensure"); var objPropertyIsEnumerable = Object.prototype.propertyIsEnumerable; module.exports = function (object) { object = Object(ensureValue(object)); var result = []; for (var key in object) { if (!objPropertyIsEnumerable.call(object, key)) continue; result.push([key, object[key]]); } return result; }; package/string_/includes/implementation.js000644 0000000261 3560116604 016115 0ustar00000000 000000 "use strict"; var indexOf = String.prototype.indexOf; module.exports = function (searchString/*, position*/) { return indexOf.call(this, searchString, arguments[1]) > -1; }; package/global-this/index.js000644 0000000152 3560116604 013130 0ustar00000000 000000 "use strict"; module.exports = require("./is-implemented")() ? globalThis : require("./implementation"); package/object/entries/index.js000644 0000000156 3560116604 013646 0ustar00000000 000000 "use strict"; module.exports = require("./is-implemented")() ? Object.entries : require("./implementation"); package/string_/includes/index.js000644 0000000173 3560116604 014201 0ustar00000000 000000 "use strict"; module.exports = require("./is-implemented")() ? String.prototype.includes : require("./implementation"); package/global-this/is-implemented.js000644 0000000250 3560116604 014734 0ustar00000000 000000 "use strict"; module.exports = function () { if (typeof globalThis !== "object") return false; if (!globalThis) return false; return globalThis.Array === Array; }; package/object/entries/is-implemented.js000644 0000000213 3560116604 015445 0ustar00000000 000000 "use strict"; module.exports = function () { try { return Object.entries({ foo: 12 })[0][0] === "foo"; } catch (e) { return false; } }; package/string_/includes/is-implemented.js000644 0000000310 3560116604 015777 0ustar00000000 000000 "use strict"; var str = "razdwatrzy"; module.exports = function () { if (typeof str.includes !== "function") return false; return str.includes("dwa") === true && str.includes("foo") === false; }; package/promise/limit.js000644 0000002746 3560116604 012423 0ustar00000000 000000 "use strict"; var ensureNaturalNumber = require("type/natural-number/ensure") , ensurePlainFunction = require("type/plain-function/ensure") , ensure = require("type/ensure") , defineFunctionLength = require("../lib/private/define-function-length"); module.exports = function (limit, callback) { limit = ensure( ["limit", limit, ensureNaturalNumber, { min: 1 }], ["callback", callback, ensurePlainFunction] )[0]; var Promise = this, ongoingCount = 0, pending = []; var onSuccess, onFailure; var release = function () { --ongoingCount; if (ongoingCount >= limit) return; var next = pending.shift(); if (!next) return; ++ongoingCount; try { next.resolve( Promise.resolve(callback.apply(next.context, next.arguments)).then( onSuccess, onFailure ) ); } catch (exception) { release(); next.reject(exception); } }; onSuccess = function (value) { release(); return value; }; onFailure = function (exception) { release(); throw exception; }; return defineFunctionLength(callback.length, function () { if (ongoingCount >= limit) { var context = this, args = arguments; return new Promise(function (resolve, reject) { pending.push({ context: context, arguments: args, resolve: resolve, reject: reject }); }); } ++ongoingCount; try { return Promise.resolve(callback.apply(this, arguments)).then(onSuccess, onFailure); } catch (exception) { return onFailure(exception); } }); }; package/string/random.js000644 0000002573 3560116604 012413 0ustar00000000 000000 "use strict"; var isObject = require("type/object/is") , ensureNaturalNumber = require("type/natural-number/ensure") , ensureString = require("type/string/ensure"); var generated = Object.create(null), random = Math.random, uniqTryLimit = 100; var getChunk = function () { return random().toString(36).slice(2); }; var getString = function (length, charset) { var str; if (charset) { var charsetLength = charset.length; str = ""; for (var i = 0; i < length; ++i) { str += charset.charAt(Math.floor(Math.random() * charsetLength)); } return str; } str = getChunk(); if (length === null) return str; while (str.length < length) str += getChunk(); return str.slice(0, length); }; module.exports = function (/* options */) { var options = arguments[0]; if (!isObject(options)) options = {}; var length = ensureNaturalNumber(options.length, { "default": 10 }) , isUnique = options.isUnique , charset = ensureString(options.charset, { isOptional: true }); var str = getString(length, charset); if (isUnique) { var count = 0; while (generated[str]) { if (++count === uniqTryLimit) { throw new Error( "Cannot generate random string.\n" + "String.random is not designed to effectively generate many short and " + "unique random strings" ); } str = getString(length); } generated[str] = true; } return str; }; package/math/round-10.js000644 0000000123 3560116604 012110 0ustar00000000 000000 "use strict"; module.exports = require("../lib/private/decimal-adjust")("round"); package/package.json000644 0000005545 3560116604 011557 0ustar00000000 000000 { "name": "ext", "version": "1.7.0", "description": "JavaScript utilities with respect to emerging standard", "author": "Mariusz Nowak (http://www.medikoo.com/)", "keywords": [ "ecmascript", "es", "es6", "extensions", "ext", "addons", "lodash", "extras", "harmony", "javascript", "polyfill", "shim", "util", "utils", "utilities" ], "repository": { "type": "git", "url": "https://github.com/medikoo/es5-ext#ext" }, "dependencies": { "type": "^2.7.2" }, "devDependencies": { "chai": "^4.3.6", "eslint": "^8.23.0", "eslint-config-medikoo": "^4.1.2", "git-list-updated": "^1.2.1", "github-release-from-cc-changelog": "^2.3.0", "husky": "^4.3.8", "lint-staged": "^13.0.3", "mocha": "^6.2.3", "nyc": "^15.1.0", "prettier-elastic": "^2.2.1", "sinon": "^8.1.1", "timers-ext": "^0.1.7" }, "husky": { "hooks": { "pre-commit": "lint-staged" } }, "lint-staged": { "*.js": [ "eslint" ], "*.{css,html,js,json,md,yaml,yml}": [ "prettier -c" ] }, "eslintIgnore": [ "_es5-ext" ], "eslintConfig": { "extends": "medikoo/es3", "root": true, "overrides": [ { "files": "global-this/implementation.js", "globals": { "__global__": true, "self": true, "window": true }, "rules": { "no-extend-native": "off", "strict": "off" } }, { "files": [ "global-this/is-implemented.js", "global-this/index.js" ], "globals": { "globalThis": true } }, { "files": "string_/camel-to-hyphen.js", "rules": { "id-length": "off" } }, { "files": "test/**/*.js", "env": { "mocha": true } }, { "files": [ "test/promise/limit.js", "test/thenable_/finally.js" ], "globals": { "Promise": true } } ] }, "prettier": { "printWidth": 100, "tabWidth": 4, "overrides": [ { "files": [ "*.md", "*.yml" ], "options": { "tabWidth": 2 } } ] }, "mocha": { "recursive": true }, "nyc": { "all": true, "exclude": [ ".github", "_es5-ext", "coverage/**", "test/**", "*.config.js" ], "reporter": [ "lcov", "html", "text-summary" ] }, "scripts": { "coverage": "nyc npm test", "lint": "eslint .", "lint:updated": "pipe-git-updated --ext=js -- eslint --ignore-pattern '!*'", "prettier-check": "prettier -c --ignore-path .gitignore \"**/*.{css,html,js,json,md,yaml,yml}\"", "prettier-check:updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier -c", "prettify": "prettier --write --ignore-path .gitignore '**/*.{css,html,js,json,md,yaml,yml}'", "prettify:updated": "pipe-git-updated ---base=main -ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier --write", "test": "mocha" }, "license": "ISC" } package/docs/string_/camel-to-hyphen.md000644 0000000550 3560116604 015171 0ustar00000000 000000 # `string.camelToHyphen()` _(ext/string\_/camel-to-hyphen)_ Convert camelCase string to hyphen separated, e.g. `oneTwoThree` into `one-to-three`. Useful when converting names from js property convention into filename convention. ```javascript const camelToHyphen = require("ext/string_/camelToHyphen"); camelToHyphen.call("razDwaTrzy"); // raz-dwa-trzy ``` package/docs/string_/capitalize.md000644 0000000402 3560116604 014320 0ustar00000000 000000 # `string.capitalize()` _(ext/string\_/capitalize)_ Capitalize input string, e.g. convert `this is a test` into `This is a test`. ```javascript const capitalize = require("ext/string_/capitalize"); capitalize.call("this is a test"); // This is a test ``` package/docs/math/ceil-10.md000644 0000000246 3560116604 012617 0ustar00000000 000000 # `Math.ceil10` _(ext/math/ceil-10)_ Decimal ceil ```javascript const ceil10 = require("ext/math/ceil-10"); ceil10(55.51, -1); // 55.6 ceil10(-59, 1); // -50; ``` package/CHANGELOG.md000644 0000007075 3560116604 011102 0ustar00000000 000000 # Changelog All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. ## [1.7.0](https://github.com/medikoo/es5-ext/compare/v1.6.0...v1.7.0) (2022-08-31) ### Features - `string.camelToHyphen` method ([b8ea4ab](https://github.com/medikoo/es5-ext/commit/b8ea4ab6c8b920ecdff224f9c92092e1c7f8cdfc)) - `string.capitalize` method ([32e7360](https://github.com/medikoo/es5-ext/commit/32e736034bd27ed25d4566b22aa93aa66c7901cf)) ## [1.6.0](https://github.com/medikoo/es5-ext/compare/v1.5.0...v1.6.0) (2021-09-24) ### Features - `Object.clear` util ([a955da4](https://github.com/medikoo/es5-ext/commit/a955da41e65a25ad87a46234bae065f096abd1d2)) ### Bug Fixes - Fix `Object.entries` to not return non enumerable properties ([44fb872](https://github.com/medikoo/es5-ext/commit/44fb87266617378d2f47a1a5baad6280bf6298a8)) ## [1.5.0](https://github.com/medikoo/es5-ext/compare/v1.3.0...v1.5.0) (2021-08-23) ### Features - `Promise.limit` ([060a05d](https://github.com/medikoo/es5-ext/commit/060a05d4751cd291c6dd7641f5a73ba9338ea7ab)) - `String.prototype.includes` ([ceebe8d](https://github.com/medikoo/es5-ext/commit/ceebe8dfd6f479d6a7e7b6cd79369291869ee2dd)) - `charset` option for `String.random` ([2a20eeb](https://github.com/medikoo/es5-ext/commit/2a20eebc5ae784e5c1aacd2c54433fe92a9464c9)) ## [1.4.0](https://github.com///compare/v1.3.0...v1.4.0) (2019-11-29) ### Features - `charset` option for `String.random` ([2a20eeb](https://github.com///commit/2a20eebc5ae784e5c1aacd2c54433fe92a9464c9)) - `String.prototype.includes` implementation ([ceebe8d](https://github.com///commit/ceebe8dfd6f479d6a7e7b6cd79369291869ee2dd)) ## [1.3.0](https://github.com///compare/v1.2.1...v1.3.0) (2019-11-28) ### Features - `String.random` util ([5b5860a](https://github.com///commit/5b5860ac545b05f00527e00295fdb4f97e4a4e5b)) ### [1.2.1](https://github.com///compare/v1.2.0...v1.2.1) (2019-11-26) ## [1.2.0](https://github.com/medikoo/ext/compare/v1.1.2...v1.2.0) (2019-11-07) ### Features - ceil10, floor10 and round10 for Math ([6a2bc4b](https://github.com/medikoo/ext/commit/6a2bc4b)) ### [1.1.2](https://github.com/medikoo/ext/compare/v1.1.1...v1.1.2) (2019-10-29) ### Bug Fixes - Improve globalThis detection ([470862d](https://github.com/medikoo/ext/commit/470862d)) ### [1.1.1](https://github.com/medikoo/ext/compare/v1.1.0...v1.1.1) (2019-10-29) ### Bug Fixes - Provide naive fallback for sealed Object.prototype case ([a8d528b](https://github.com/medikoo/ext/commit/a8d528b)) - Workaournd Safari incompatibility case ([0b051e6](https://github.com/medikoo/ext/commit/0b051e6)) ## [1.1.0](https://github.com/medikoo/ext/compare/v1.0.3...v1.1.0) (2019-10-21) ### Features - Object.entries implementation ([cf51e45](https://github.com/medikoo/ext/commit/cf51e45)) ### [1.0.3](https://github.com/medikoo/ext/compare/v1.0.1...v1.0.3) (2019-07-03) Remove obsolete files from publication ### [1.0.2](https://github.com/medikoo/ext/compare/v1.0.1...v1.0.2) (2019-07-03) (no changes) ### [1.0.1](https://github.com/medikoo/ext/compare/v1.0.0...v1.0.1) (2019-07-03) Prettify ## 1.0.0 (2019-07-03) ### Features - `function/identity` (adapted from `es5-ext`) ([f0102af](https://github.com/medikoo/ext/commit/f0102af)) - `thenable/finally` (adapted from `es5-ext`) ([a8494ac](https://github.com/medikoo/ext/commit/a8494ac)) - `global-this/is-implemented` ([3a80904](https://github.com/medikoo/ext/commit/3a80904)) - `globalThis` (mostly adapted from `es5-ext`) ([6559bd3](https://github.com/medikoo/ext/commit/6559bd3)) package/docs/object/clear.md000644 0000000350 3560116604 013064 0ustar00000000 000000 # `Object.clear` _(ext/object/clear)_ Deletes all own, enumerable, non-symbol properties in the object ```javascript const clear = require("ext/object/clear"); const obj = { foo: "bar" }; clear(obj); Object.keys(obj); // [] ``` package/docs/object/entries.md000644 0000000600 3560116604 013445 0ustar00000000 000000 # `Object.entries` _(ext/object/entries)_ [Object.entries](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries) implementation. Returns native `Object.entries` if it's implemented, otherwise library implementation is returned ```javascript const entries = require("ext/object/entries"); entries({ foo: "bar" }); // [["foo", "bar"]] ``` package/docs/thenable_/finally.md000644 0000000341 3560116604 014107 0ustar00000000 000000 # `thenable.finally` _(ext/thenable\_/finally)_ `finally` method for any _thenable_ input ```javascript const finally = require("ext/thenable_/finally"); finally.call(thenable, () => console.log("Thenable resolved")); ``` package/docs/math/floor-10.md000644 0000000252 3560116604 013021 0ustar00000000 000000 # `Math.floor10` _(ext/math/floor-10)_ Decimal floor ```javascript const floor10 = require("ext/math/floor-10"); floor10(55.59, -1); // 55.5 floor10(59, 1); // 50 ``` package/docs/global-this.md000644 0000000465 3560116604 012744 0ustar00000000 000000 # `globalThis` _(ext/global-this)_ Returns global object. Resolve native [globalThis](https://github.com/tc39/proposal-global) if implemented, otherwise fallback to internal resolution of a global object. ```javascript const globalThis = require("ext/global-this"); globalThis.Array === Array; // true ``` package/docs/function/identity.md000644 0000000252 3560116604 014207 0ustar00000000 000000 # `Function.identity` _(ext/function/identity)_ Returns input argument. ```javascript const identity = require("ext/function/identity"); identity("foo"); // "foo" ``` package/docs/string_/includes.md000644 0000000653 3560116604 014011 0ustar00000000 000000 # `string.includes(position = 0)` _(ext/string\_/includes)_ `includes` method for strings. Resolve native [includes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) if implemented, otherwise fallback to shim implementation. ```javascript const includes = require("ext/string_/includes"); includes.call("razdwa", "raz"); // true includes.call("razdwa", "trzy"); // false ``` package/docs/promise/limit.md000644 0000000631 3560116604 013326 0ustar00000000 000000 # `Promise.limit` _(ext/promise/limit)_ Helps to limit concurrency of asynchronous operations. ```javascript const limit = require("ext/promise/limit").bind(Promise); const limittedAsyncFunction = limit(2, asyncFunction); imittedAsyncFunction(); // Async operation started imittedAsyncFunction(); // Async operation started imittedAsyncFunction(); // On hold until one of previously started finalizes ``` package/docs/string/random.md000644 0000001447 3560116604 013326 0ustar00000000 000000 # `String.random(options = { ... })` _(ext/string/random)_ Returns generated random string, contained only of ascii cars `a-z` and `0-1`. By default returns string of length `10`. ```javascript const random = require("ext/string/random"); random(); // "upcfns0i4t" random({ length: 3 }); // "5tw" ``` ## Supported options: ### `isUnique: false` Ensures generated string is unique among ones already returned. _Note: When not applying this setting, accidental generation of same string is still highly unlikely. Provided option is just to provide a mean to eliminate possibility of an edge case of duplicate string being returned_ ### `length: 10` Desired length of result string ### `charset: null` Fixed list of possible characters ```javascript random({ charset: "abc" }); // "bacbccbbac" ``` package/README.md000644 0000002552 3560116604 010543 0ustar00000000 000000 [![Build status][build-image]][build-url] [![npm version][npm-image]][npm-url] # ext _(Previously known as `es5-ext`)_ ## JavaScript language extensions (with respect to evolving standard) Non-standard or soon to be standard language utilities in a future proof, non-invasive form. Doesn't enforce transpilation step. Where it's applicable utilities/extensions are safe to use in all ES3+ implementations. ### Installation ```bash npm install ext ``` ### Utilities - [`globalThis`](docs/global-this.md) - `Function` - [`identity`](docs/function/identity.md) - `Math` - [`ceil10`](docs/math/ceil-10.md) - [`floor10`](docs/math/floor-10.md) - [`round10`](docs/math/round-10.md) - `Object` - [`clear`](docs/object/clear.md) - [`entries`](docs/object/entries.md) - `Promise` - [`limit`](docs/promise/limit.md) - `String` - [`random`](docs/string/random.md) - `String.prototype` - [`campelToHyphen`](docs/string_/camel-to-hyphen.md) - [`capitalize`](docs/string_/capitalize.md) - [`includes`](docs/string_/includes.md) - `Thenable.prototype` - [`finally`](docs/thenable_/finally.md) [build-image]: https://github.com/medikoo/es5-ext/workflows/Integrate%20[ext]/badge.svg [build-url]: https://github.com/medikoo/es5-ext/actions?query=workflow%3AIntegrate%20[ext] [npm-image]: https://img.shields.io/npm/v/ext.svg [npm-url]: https://www.npmjs.com/package/ext package/docs/math/round-10.md000644 0000000261 3560116604 013027 0ustar00000000 000000 # `Math.round10` _(ext/math/round-10)_ Decimal round ```javascript const round10 = require("ext/math/round-10"); round10(55.549, -1); // 55.5 round10(1.005, -2); // 1.01 ```