@thi.ng/strings
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -6,2 +6,13 @@ # Change Log | ||
<a name="0.2.0"></a> | ||
# [0.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/strings@0.1.1...@thi.ng/strings@0.2.0) (2018-08-08) | ||
### Features | ||
* **strings:** add opt prefix arg for radix() ([5864f2c](https://github.com/thi-ng/umbrella/commit/5864f2c)) | ||
<a name="0.1.1"></a> | ||
@@ -8,0 +19,0 @@ ## [0.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/strings@0.1.0...@thi.ng/strings@0.1.1) (2018-08-08) |
{ | ||
"name": "@thi.ng/strings", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Various string formatting & utility functions", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
import { Stringer } from "./api"; | ||
/** | ||
* Returns a `Stringer` which formats given numbers to `radix` and `len`. | ||
* Returns a `Stringer` which formats given numbers to `radix`, `len` | ||
* and with optional prefix (not included in `len`). | ||
* | ||
* @param radix | ||
* @param len | ||
* @param prefix | ||
*/ | ||
export declare const radix: (radix: number, len: number) => Stringer<number>; | ||
export declare const radix: (radix: number, len: number, prefix?: string) => Stringer<number>; | ||
export declare const B8: Stringer<number>; | ||
@@ -10,0 +12,0 @@ export declare const U8: Stringer<number>; |
@@ -6,12 +6,14 @@ "use strict"; | ||
/** | ||
* Returns a `Stringer` which formats given numbers to `radix` and `len`. | ||
* Returns a `Stringer` which formats given numbers to `radix`, `len` | ||
* and with optional prefix (not included in `len`). | ||
* | ||
* @param radix | ||
* @param len | ||
* @param prefix | ||
*/ | ||
exports.radix = memoizej_1.memoizeJ((radix, n) => { | ||
exports.radix = memoizej_1.memoizeJ((radix, n, prefix = "") => { | ||
const buf = repeat_1.repeat("0", n); | ||
return (x) => { | ||
x = (x >>> 0).toString(radix); | ||
return x.length < n ? buf.substr(x.length) + x : x; | ||
return prefix + (x.length < n ? buf.substr(x.length) + x : x); | ||
}; | ||
@@ -18,0 +20,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22592
259