@thi.ng/strings 2.1.7 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@thi.ng/strings",
3
- "version": "2.1.7",
3
+ "version": "3.0.0",
4
4
  "description": "Various string formatting & utility functions",
5
+ "type": "module",
5
6
  "module": "./index.js",
6
- "main": "./lib/index.js",
7
- "umd:main": "./lib/index.umd.js",
8
7
  "typings": "./index.d.ts",
8
+ "sideEffects": false,
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "https://github.com/thi-ng/umbrella.git"
@@ -24,30 +24,24 @@
24
24
  "author": "Karsten Schmidt <k+npm@thi.ng>",
25
25
  "license": "Apache-2.0",
26
26
  "scripts": {
27
- "build": "yarn clean && yarn build:es6 && node ../../scripts/bundle-module",
28
- "build:release": "yarn clean && yarn build:es6 && node ../../scripts/bundle-module all",
29
- "build:es6": "tsc --declaration",
30
- "build:test": "rimraf build && tsc -p test/tsconfig.json",
31
- "build:check": "tsc --isolatedModules --noEmit",
32
- "test": "mocha test",
33
- "cover": "nyc mocha test && nyc report --reporter=lcov",
34
- "clean": "rimraf *.js *.d.ts *.map .nyc_output build coverage doc lib",
35
- "doc:readme": "ts-node -P ../../tools/tsconfig.json ../../tools/src/readme.ts",
36
- "doc": "typedoc --excludePrivate --out doc --theme ../../tools/doc/typedoc-theme src/index.ts",
27
+ "build": "yarn clean && tsc --declaration",
28
+ "clean": "rimraf *.js *.d.ts *.map doc",
29
+ "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
37
30
  "doc:ae": "mkdir -p .ae/doc .ae/temp && node_modules/.bin/api-extractor run --local --verbose",
38
- "pub": "yarn build:release && yarn publish --access public"
31
+ "doc:readme": "yarn doc:stats && ../../scripts/node-esm ../../tools/src/readme.ts",
32
+ "doc:stats": "../../scripts/node-esm ../../tools/src/module-stats.ts",
33
+ "pub": "yarn build && yarn publish --access public",
34
+ "test": "testament test"
39
35
  },
40
36
  "dependencies": {
41
- "@thi.ng/api": "^7.2.0",
42
- "@thi.ng/errors": "^1.3.4",
43
- "@thi.ng/hex": "^1.0.4",
44
- "@thi.ng/memoize": "^2.1.21"
37
+ "@thi.ng/api": "^8.0.0",
38
+ "@thi.ng/errors": "^2.0.0",
39
+ "@thi.ng/hex": "^2.0.0",
40
+ "@thi.ng/memoize": "^3.0.0"
41
+ },
42
+ "devDependencies": {
43
+ "@thi.ng/testament": "^0.1.0"
45
44
  },
46
- "files": [
47
- "*.js",
48
- "*.d.ts",
49
- "lib"
50
- ],
51
45
  "keywords": [
52
46
  "ansi",
53
47
  "composition",
@@ -75,9 +69,122 @@
75
69
  "publishConfig": {
76
70
  "access": "public"
77
71
  },
78
- "sideEffects": false,
72
+ "files": [
73
+ "*.js",
74
+ "*.d.ts"
75
+ ],
76
+ "exports": {
77
+ ".": {
78
+ "import": "./index.js"
79
+ },
80
+ "./ansi": {
81
+ "import": "./ansi.js"
82
+ },
83
+ "./api": {
84
+ "import": "./api.js"
85
+ },
86
+ "./case": {
87
+ "import": "./case.js"
88
+ },
89
+ "./center": {
90
+ "import": "./center.js"
91
+ },
92
+ "./cursor": {
93
+ "import": "./cursor.js"
94
+ },
95
+ "./escape": {
96
+ "import": "./escape.js"
97
+ },
98
+ "./float": {
99
+ "import": "./float.js"
100
+ },
101
+ "./format": {
102
+ "import": "./format.js"
103
+ },
104
+ "./groups": {
105
+ "import": "./groups.js"
106
+ },
107
+ "./hollerith": {
108
+ "import": "./hollerith.js"
109
+ },
110
+ "./initials": {
111
+ "import": "./initials.js"
112
+ },
113
+ "./int": {
114
+ "import": "./int.js"
115
+ },
116
+ "./interpolate": {
117
+ "import": "./interpolate.js"
118
+ },
119
+ "./join": {
120
+ "import": "./join.js"
121
+ },
122
+ "./pad-left": {
123
+ "import": "./pad-left.js"
124
+ },
125
+ "./pad-right": {
126
+ "import": "./pad-right.js"
127
+ },
128
+ "./parse": {
129
+ "import": "./parse.js"
130
+ },
131
+ "./percent": {
132
+ "import": "./percent.js"
133
+ },
134
+ "./radix": {
135
+ "import": "./radix.js"
136
+ },
137
+ "./range": {
138
+ "import": "./range.js"
139
+ },
140
+ "./repeat": {
141
+ "import": "./repeat.js"
142
+ },
143
+ "./ruler": {
144
+ "import": "./ruler.js"
145
+ },
146
+ "./slugify": {
147
+ "import": "./slugify.js"
148
+ },
149
+ "./splice": {
150
+ "import": "./splice.js"
151
+ },
152
+ "./split": {
153
+ "import": "./split.js"
154
+ },
155
+ "./stringify": {
156
+ "import": "./stringify.js"
157
+ },
158
+ "./tabs": {
159
+ "import": "./tabs.js"
160
+ },
161
+ "./trim": {
162
+ "import": "./trim.js"
163
+ },
164
+ "./truncate-left": {
165
+ "import": "./truncate-left.js"
166
+ },
167
+ "./truncate": {
168
+ "import": "./truncate.js"
169
+ },
170
+ "./units": {
171
+ "import": "./units.js"
172
+ },
173
+ "./uuid": {
174
+ "import": "./uuid.js"
175
+ },
176
+ "./vector": {
177
+ "import": "./vector.js"
178
+ },
179
+ "./word-wrap": {
180
+ "import": "./word-wrap.js"
181
+ },
182
+ "./wrap": {
183
+ "import": "./wrap.js"
184
+ }
185
+ },
79
186
  "thi.ng": {
80
187
  "year": 2015
81
188
  },
82
- "gitHead": "d971cb3f9b215a95483f78f1a8614015e331146f"
189
+ "gitHead": "9ac1344b38b565eb894306fbf72233b6c0b2d115"
83
190
  }
package/pad-left.js CHANGED
@@ -1,4 +1,4 @@
1
- import { memoizeJ } from "@thi.ng/memoize";
1
+ import { memoizeJ } from "@thi.ng/memoize/memoizej";
2
2
  import { repeat } from "./repeat";
3
3
  /**
4
4
  * @param n - target length
package/pad-right.js CHANGED
@@ -1,4 +1,4 @@
1
- import { memoizeJ } from "@thi.ng/memoize";
1
+ import { memoizeJ } from "@thi.ng/memoize/memoizej";
2
2
  import { repeat } from "./repeat";
3
3
  /**
4
4
  * @param n - target length
package/radix.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { U16 as $16, U24 as $24, U32 as $32, U64HL, U8 as $8, } from "@thi.ng/hex";
2
- import { memoizeJ } from "@thi.ng/memoize";
2
+ import { memoizeJ } from "@thi.ng/memoize/memoizej";
3
3
  import { repeat } from "./repeat";
4
4
  /**
5
5
  * Returns a {@link Stringer} which formats given numbers to `radix`, `len` and
package/repeat.js CHANGED
@@ -1,4 +1,4 @@
1
- import { memoizeJ } from "@thi.ng/memoize";
1
+ import { memoizeJ } from "@thi.ng/memoize/memoizej";
2
2
  /**
3
3
  * @param ch - character
4
4
  * @param n - repeat count
package/splice.js CHANGED
@@ -1,4 +1,4 @@
1
- import { illegalArgs } from "@thi.ng/errors";
1
+ import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
2
2
  /**
3
3
  * Forms a new strings which inserts given `insert` string into `src`
4
4
  * string at `from` position and appends remaining `src` chars from
package/trim.js CHANGED
@@ -1,4 +1,4 @@
1
- import { memoize1 } from "@thi.ng/memoize";
1
+ import { memoize1 } from "@thi.ng/memoize/memoize1";
2
2
  /**
3
3
  * Higher order trim function (both sides) with support for user defined
4
4
  * trimmable characters (default: whitespace only).
package/truncate-left.js CHANGED
@@ -1,2 +1,4 @@
1
- import { memoizeJ } from "@thi.ng/memoize";
2
- export const truncateLeft = memoizeJ((n, prefix = "") => (x) => x.length > n ? prefix + x.substr(x.length - n + prefix.length) : x);
1
+ import { memoizeJ } from "@thi.ng/memoize/memoizej";
2
+ export const truncateLeft = memoizeJ((n, prefix = "") => (x) => x.length > n
3
+ ? prefix + x.substr(x.length - n + prefix.length)
4
+ : x);
package/truncate.js CHANGED
@@ -1,4 +1,4 @@
1
- import { memoizeJ } from "@thi.ng/memoize";
1
+ import { memoizeJ } from "@thi.ng/memoize/memoizej";
2
2
  export const truncate = memoizeJ((n, suffix = "") => (x) => x.length > n ? x.substr(0, n - suffix.length) + suffix : x);
3
3
  /**
4
4
  * Alias for {@link truncate}
package/units.js CHANGED
@@ -1,4 +1,4 @@
1
- import { memoizeJ } from "@thi.ng/memoize";
1
+ import { memoizeJ } from "@thi.ng/memoize/memoizej";
2
2
  export const units = memoizeJ((exp, base, prec = 2) => {
3
3
  const groups = exp
4
4
  .map((x) => [
package/vector.js CHANGED
@@ -1,4 +1,4 @@
1
- import { memoizeJ } from "@thi.ng/memoize";
1
+ import { memoizeJ } from "@thi.ng/memoize/memoizej";
2
2
  import { float } from "./float";
3
3
  /**
4
4
  * Higher order formatter for n-D vectors, with each element formatted using
package/word-wrap.js CHANGED
@@ -8,9 +8,9 @@ import { split } from "./split";
8
8
  * @internal
9
9
  */
10
10
  class Line {
11
+ n = 0;
12
+ w = [];
11
13
  constructor(word, n) {
12
- this.n = 0;
13
- this.w = [];
14
14
  word != null && this.add(word, n);
15
15
  }
16
16
  add(word, n = word.length) {
@@ -114,7 +114,13 @@ export const wordWrapLine = (line, opts, acc = []) => {
114
114
  acc.push(new Line());
115
115
  return acc;
116
116
  }
117
- const $opts = Object.assign({ width: 80, min: 4, hard: false, splitter: SPLIT_PLAIN }, opts);
117
+ const $opts = {
118
+ width: 80,
119
+ min: 4,
120
+ hard: false,
121
+ splitter: SPLIT_PLAIN,
122
+ ...opts,
123
+ };
118
124
  for (let word of split(line, opts.delimWord || /\s/g)) {
119
125
  const curr = acc[acc.length - 1];
120
126
  wrapWord(word, $opts, curr && curr.n > 0 ? curr.n + 1 : 0, acc);
package/wrap.js CHANGED
@@ -1,4 +1,4 @@
1
- import { memoizeJ } from "@thi.ng/memoize";
1
+ import { memoizeJ } from "@thi.ng/memoize/memoizej";
2
2
  /**
3
3
  * Returns a {@link Stringer} which wrap inputs with given `pad` string on
4
4
  * both sides.