@vitessce/utils 3.1.0 → 3.1.2

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/dist/index.js CHANGED
@@ -1,3 +1,393 @@
1
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
2
+ function getDefaultExportFromCjs(x) {
3
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
4
+ }
5
+ function getAugmentedNamespace(n) {
6
+ if (n.__esModule)
7
+ return n;
8
+ var f = n.default;
9
+ if (typeof f == "function") {
10
+ var a = function a2() {
11
+ if (this instanceof a2) {
12
+ var args = [null];
13
+ args.push.apply(args, arguments);
14
+ var Ctor = Function.bind.apply(f, args);
15
+ return new Ctor();
16
+ }
17
+ return f.apply(this, arguments);
18
+ };
19
+ a.prototype = f.prototype;
20
+ } else
21
+ a = {};
22
+ Object.defineProperty(a, "__esModule", { value: true });
23
+ Object.keys(n).forEach(function(k) {
24
+ var d = Object.getOwnPropertyDescriptor(n, k);
25
+ Object.defineProperty(a, k, d.get ? d : {
26
+ enumerable: true,
27
+ get: function() {
28
+ return n[k];
29
+ }
30
+ });
31
+ });
32
+ return a;
33
+ }
34
+ function commonjsRequire(path) {
35
+ throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
36
+ }
37
+ var pluralize$1 = { exports: {} };
38
+ (function(module2, exports2) {
39
+ (function(root2, pluralize2) {
40
+ if (typeof commonjsRequire === "function" && true && true) {
41
+ module2.exports = pluralize2();
42
+ } else {
43
+ root2.pluralize = pluralize2();
44
+ }
45
+ })(commonjsGlobal, function() {
46
+ var pluralRules = [];
47
+ var singularRules = [];
48
+ var uncountables = {};
49
+ var irregularPlurals = {};
50
+ var irregularSingles = {};
51
+ function sanitizeRule(rule) {
52
+ if (typeof rule === "string") {
53
+ return new RegExp("^" + rule + "$", "i");
54
+ }
55
+ return rule;
56
+ }
57
+ function restoreCase(word, token) {
58
+ if (word === token)
59
+ return token;
60
+ if (word === word.toLowerCase())
61
+ return token.toLowerCase();
62
+ if (word === word.toUpperCase())
63
+ return token.toUpperCase();
64
+ if (word[0] === word[0].toUpperCase()) {
65
+ return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
66
+ }
67
+ return token.toLowerCase();
68
+ }
69
+ function interpolate(str, args) {
70
+ return str.replace(/\$(\d{1,2})/g, function(match, index) {
71
+ return args[index] || "";
72
+ });
73
+ }
74
+ function replace(word, rule) {
75
+ return word.replace(rule[0], function(match, index) {
76
+ var result = interpolate(rule[1], arguments);
77
+ if (match === "") {
78
+ return restoreCase(word[index - 1], result);
79
+ }
80
+ return restoreCase(match, result);
81
+ });
82
+ }
83
+ function sanitizeWord(token, word, rules) {
84
+ if (!token.length || uncountables.hasOwnProperty(token)) {
85
+ return word;
86
+ }
87
+ var len = rules.length;
88
+ while (len--) {
89
+ var rule = rules[len];
90
+ if (rule[0].test(word))
91
+ return replace(word, rule);
92
+ }
93
+ return word;
94
+ }
95
+ function replaceWord(replaceMap, keepMap, rules) {
96
+ return function(word) {
97
+ var token = word.toLowerCase();
98
+ if (keepMap.hasOwnProperty(token)) {
99
+ return restoreCase(word, token);
100
+ }
101
+ if (replaceMap.hasOwnProperty(token)) {
102
+ return restoreCase(word, replaceMap[token]);
103
+ }
104
+ return sanitizeWord(token, word, rules);
105
+ };
106
+ }
107
+ function checkWord(replaceMap, keepMap, rules, bool) {
108
+ return function(word) {
109
+ var token = word.toLowerCase();
110
+ if (keepMap.hasOwnProperty(token))
111
+ return true;
112
+ if (replaceMap.hasOwnProperty(token))
113
+ return false;
114
+ return sanitizeWord(token, token, rules) === token;
115
+ };
116
+ }
117
+ function pluralize2(word, count, inclusive) {
118
+ var pluralized = count === 1 ? pluralize2.singular(word) : pluralize2.plural(word);
119
+ return (inclusive ? count + " " : "") + pluralized;
120
+ }
121
+ pluralize2.plural = replaceWord(
122
+ irregularSingles,
123
+ irregularPlurals,
124
+ pluralRules
125
+ );
126
+ pluralize2.isPlural = checkWord(
127
+ irregularSingles,
128
+ irregularPlurals,
129
+ pluralRules
130
+ );
131
+ pluralize2.singular = replaceWord(
132
+ irregularPlurals,
133
+ irregularSingles,
134
+ singularRules
135
+ );
136
+ pluralize2.isSingular = checkWord(
137
+ irregularPlurals,
138
+ irregularSingles,
139
+ singularRules
140
+ );
141
+ pluralize2.addPluralRule = function(rule, replacement) {
142
+ pluralRules.push([sanitizeRule(rule), replacement]);
143
+ };
144
+ pluralize2.addSingularRule = function(rule, replacement) {
145
+ singularRules.push([sanitizeRule(rule), replacement]);
146
+ };
147
+ pluralize2.addUncountableRule = function(word) {
148
+ if (typeof word === "string") {
149
+ uncountables[word.toLowerCase()] = true;
150
+ return;
151
+ }
152
+ pluralize2.addPluralRule(word, "$0");
153
+ pluralize2.addSingularRule(word, "$0");
154
+ };
155
+ pluralize2.addIrregularRule = function(single, plural) {
156
+ plural = plural.toLowerCase();
157
+ single = single.toLowerCase();
158
+ irregularSingles[single] = plural;
159
+ irregularPlurals[plural] = single;
160
+ };
161
+ [
162
+ // Pronouns.
163
+ ["I", "we"],
164
+ ["me", "us"],
165
+ ["he", "they"],
166
+ ["she", "they"],
167
+ ["them", "them"],
168
+ ["myself", "ourselves"],
169
+ ["yourself", "yourselves"],
170
+ ["itself", "themselves"],
171
+ ["herself", "themselves"],
172
+ ["himself", "themselves"],
173
+ ["themself", "themselves"],
174
+ ["is", "are"],
175
+ ["was", "were"],
176
+ ["has", "have"],
177
+ ["this", "these"],
178
+ ["that", "those"],
179
+ // Words ending in with a consonant and `o`.
180
+ ["echo", "echoes"],
181
+ ["dingo", "dingoes"],
182
+ ["volcano", "volcanoes"],
183
+ ["tornado", "tornadoes"],
184
+ ["torpedo", "torpedoes"],
185
+ // Ends with `us`.
186
+ ["genus", "genera"],
187
+ ["viscus", "viscera"],
188
+ // Ends with `ma`.
189
+ ["stigma", "stigmata"],
190
+ ["stoma", "stomata"],
191
+ ["dogma", "dogmata"],
192
+ ["lemma", "lemmata"],
193
+ ["schema", "schemata"],
194
+ ["anathema", "anathemata"],
195
+ // Other irregular rules.
196
+ ["ox", "oxen"],
197
+ ["axe", "axes"],
198
+ ["die", "dice"],
199
+ ["yes", "yeses"],
200
+ ["foot", "feet"],
201
+ ["eave", "eaves"],
202
+ ["goose", "geese"],
203
+ ["tooth", "teeth"],
204
+ ["quiz", "quizzes"],
205
+ ["human", "humans"],
206
+ ["proof", "proofs"],
207
+ ["carve", "carves"],
208
+ ["valve", "valves"],
209
+ ["looey", "looies"],
210
+ ["thief", "thieves"],
211
+ ["groove", "grooves"],
212
+ ["pickaxe", "pickaxes"],
213
+ ["passerby", "passersby"]
214
+ ].forEach(function(rule) {
215
+ return pluralize2.addIrregularRule(rule[0], rule[1]);
216
+ });
217
+ [
218
+ [/s?$/i, "s"],
219
+ [/[^\u0000-\u007F]$/i, "$0"],
220
+ [/([^aeiou]ese)$/i, "$1"],
221
+ [/(ax|test)is$/i, "$1es"],
222
+ [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
223
+ [/(e[mn]u)s?$/i, "$1s"],
224
+ [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
225
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1i"],
226
+ [/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
227
+ [/(seraph|cherub)(?:im)?$/i, "$1im"],
228
+ [/(her|at|gr)o$/i, "$1oes"],
229
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, "$1a"],
230
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, "$1a"],
231
+ [/sis$/i, "ses"],
232
+ [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
233
+ [/([^aeiouy]|qu)y$/i, "$1ies"],
234
+ [/([^ch][ieo][ln])ey$/i, "$1ies"],
235
+ [/(x|ch|ss|sh|zz)$/i, "$1es"],
236
+ [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
237
+ [/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
238
+ [/(pe)(?:rson|ople)$/i, "$1ople"],
239
+ [/(child)(?:ren)?$/i, "$1ren"],
240
+ [/eaux$/i, "$0"],
241
+ [/m[ae]n$/i, "men"],
242
+ ["thou", "you"]
243
+ ].forEach(function(rule) {
244
+ return pluralize2.addPluralRule(rule[0], rule[1]);
245
+ });
246
+ [
247
+ [/s$/i, ""],
248
+ [/(ss)$/i, "$1"],
249
+ [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
250
+ [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
251
+ [/ies$/i, "y"],
252
+ [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, "$1ie"],
253
+ [/\b(mon|smil)ies$/i, "$1ey"],
254
+ [/\b((?:tit)?m|l)ice$/i, "$1ouse"],
255
+ [/(seraph|cherub)im$/i, "$1"],
256
+ [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, "$1"],
257
+ [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, "$1sis"],
258
+ [/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
259
+ [/(test)(?:is|es)$/i, "$1is"],
260
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1us"],
261
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, "$1um"],
262
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, "$1on"],
263
+ [/(alumn|alg|vertebr)ae$/i, "$1a"],
264
+ [/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
265
+ [/(matr|append)ices$/i, "$1ix"],
266
+ [/(pe)(rson|ople)$/i, "$1rson"],
267
+ [/(child)ren$/i, "$1"],
268
+ [/(eau)x?$/i, "$1"],
269
+ [/men$/i, "man"]
270
+ ].forEach(function(rule) {
271
+ return pluralize2.addSingularRule(rule[0], rule[1]);
272
+ });
273
+ [
274
+ // Singular words with no plurals.
275
+ "adulthood",
276
+ "advice",
277
+ "agenda",
278
+ "aid",
279
+ "aircraft",
280
+ "alcohol",
281
+ "ammo",
282
+ "analytics",
283
+ "anime",
284
+ "athletics",
285
+ "audio",
286
+ "bison",
287
+ "blood",
288
+ "bream",
289
+ "buffalo",
290
+ "butter",
291
+ "carp",
292
+ "cash",
293
+ "chassis",
294
+ "chess",
295
+ "clothing",
296
+ "cod",
297
+ "commerce",
298
+ "cooperation",
299
+ "corps",
300
+ "debris",
301
+ "diabetes",
302
+ "digestion",
303
+ "elk",
304
+ "energy",
305
+ "equipment",
306
+ "excretion",
307
+ "expertise",
308
+ "firmware",
309
+ "flounder",
310
+ "fun",
311
+ "gallows",
312
+ "garbage",
313
+ "graffiti",
314
+ "hardware",
315
+ "headquarters",
316
+ "health",
317
+ "herpes",
318
+ "highjinks",
319
+ "homework",
320
+ "housework",
321
+ "information",
322
+ "jeans",
323
+ "justice",
324
+ "kudos",
325
+ "labour",
326
+ "literature",
327
+ "machinery",
328
+ "mackerel",
329
+ "mail",
330
+ "media",
331
+ "mews",
332
+ "moose",
333
+ "music",
334
+ "mud",
335
+ "manga",
336
+ "news",
337
+ "only",
338
+ "personnel",
339
+ "pike",
340
+ "plankton",
341
+ "pliers",
342
+ "police",
343
+ "pollution",
344
+ "premises",
345
+ "rain",
346
+ "research",
347
+ "rice",
348
+ "salmon",
349
+ "scissors",
350
+ "series",
351
+ "sewage",
352
+ "shambles",
353
+ "shrimp",
354
+ "software",
355
+ "species",
356
+ "staff",
357
+ "swine",
358
+ "tennis",
359
+ "traffic",
360
+ "transportation",
361
+ "trout",
362
+ "tuna",
363
+ "wealth",
364
+ "welfare",
365
+ "whiting",
366
+ "wildebeest",
367
+ "wildlife",
368
+ "you",
369
+ /pok[eé]mon$/i,
370
+ // Regexes.
371
+ /[^aeiou]ese$/i,
372
+ // "chinese", "japanese"
373
+ /deer$/i,
374
+ // "deer", "reindeer"
375
+ /fish$/i,
376
+ // "fish", "blowfish", "angelfish"
377
+ /measles$/i,
378
+ /o[iu]s$/i,
379
+ // "carnivorous"
380
+ /pox$/i,
381
+ // "chickpox", "smallpox"
382
+ /sheep$/i
383
+ ].forEach(pluralize2.addUncountableRule);
384
+ return pluralize2;
385
+ });
386
+ })(pluralize$1);
387
+ var pluralizeExports = pluralize$1.exports;
388
+ const plur = /* @__PURE__ */ getDefaultExportFromCjs(pluralizeExports);
389
+ plur.addPluralRule("glomerulus", "glomeruli");
390
+ plur.addPluralRule("interstitium", "interstitia");
1
391
  function fromEntries$1(iterable) {
2
392
  return [...iterable].reduce((obj, { 0: key, 1: val }) => Object.assign(obj, { [key]: val }), {});
3
393
  }
@@ -8,6 +398,9 @@ function commaNumber(n) {
8
398
  function capitalize$1(word) {
9
399
  return word ? word.charAt(0).toUpperCase() + word.slice(1) : "";
10
400
  }
401
+ function pluralize(word, count = null) {
402
+ return plur(word, count);
403
+ }
11
404
  function getLongestString(strings) {
12
405
  return strings.reduce(
13
406
  (prevLongest, currentValue) => prevLongest.length > currentValue.length ? prevLongest : currentValue
@@ -1241,36 +1634,6 @@ function isEqual(value, other) {
1241
1634
  function isNil(value) {
1242
1635
  return value == null;
1243
1636
  }
1244
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
1245
- function getAugmentedNamespace(n) {
1246
- if (n.__esModule)
1247
- return n;
1248
- var f = n.default;
1249
- if (typeof f == "function") {
1250
- var a = function a2() {
1251
- if (this instanceof a2) {
1252
- var args = [null];
1253
- args.push.apply(args, arguments);
1254
- var Ctor = Function.bind.apply(f, args);
1255
- return new Ctor();
1256
- }
1257
- return f.apply(this, arguments);
1258
- };
1259
- a.prototype = f.prototype;
1260
- } else
1261
- a = {};
1262
- Object.defineProperty(a, "__esModule", { value: true });
1263
- Object.keys(n).forEach(function(k) {
1264
- var d = Object.getOwnPropertyDescriptor(n, k);
1265
- Object.defineProperty(a, k, d.get ? d : {
1266
- enumerable: true,
1267
- get: function() {
1268
- return n[k];
1269
- }
1270
- });
1271
- });
1272
- return a;
1273
- }
1274
1637
  var concaveman$1 = { exports: {} };
1275
1638
  var rbush_min = { exports: {} };
1276
1639
  (function(module2, exports2) {
@@ -1980,6 +2343,8 @@ function convexHull(points) {
1980
2343
  lower.pop();
1981
2344
  return lower.concat(upper);
1982
2345
  }
2346
+ plur.addPluralRule("glomerulus", "glomeruli");
2347
+ plur.addPluralRule("interstitium", "interstitia");
1983
2348
  function fromEntries(iterable) {
1984
2349
  return [...iterable].reduce((obj, { 0: key, 1: val }) => Object.assign(obj, { [key]: val }), {});
1985
2350
  }
@@ -15764,5 +16129,6 @@ export {
15764
16129
  getLongestString,
15765
16130
  getNextScope$1 as getNextScope,
15766
16131
  getStatsForResolution,
15767
- getValueTransformFunction
16132
+ getValueTransformFunction,
16133
+ pluralize
15768
16134
  };
@@ -6,6 +6,12 @@ export function commaNumber(n: any): string;
6
6
  * @returns {string} The word parameter with the first letter capitalized.
7
7
  */
8
8
  export function capitalize(word: string): string;
9
+ /**
10
+ * Capitalize a the first letter of a string.
11
+ * @param {string} word A string to capitalize.
12
+ * @returns {string} The word parameter with the first letter capitalized.
13
+ */
14
+ export function pluralize(word: string, count?: null): string;
9
15
  /**
10
16
  * Get the longest string in the array of strings.
11
17
  * @param {string[]} strings The array of strings.
@@ -1 +1 @@
1
- {"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../src/root.js"],"names":[],"mappings":"AAIA,gDAGC;AAED,4CAGC;AAED;;;;GAIG;AACH,iCAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,0CAHW,MAAM,EAAE,UASlB;AAED;;;;;;;;;GASG;AACH,yCAHW,MAAM,EAAE,GACN,MAAM,CAuClB"}
1
+ {"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../src/root.js"],"names":[],"mappings":"AAQA,gDAGC;AAED,4CAGC;AAED;;;;GAIG;AACH,iCAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,gCAHW,MAAM,iBACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,0CAHW,MAAM,EAAE,UASlB;AAED;;;;;;;;;GASG;AACH,yCAHW,MAAM,EAAE,GACN,MAAM,CAuClB"}
package/dist-tsc/root.js CHANGED
@@ -1,5 +1,8 @@
1
1
  /* eslint-disable no-plusplus */
2
2
  // Originally in src/utils.js
3
+ import plur from 'pluralize';
4
+ plur.addPluralRule('glomerulus', 'glomeruli');
5
+ plur.addPluralRule('interstitium', 'interstitia');
3
6
  // Adapted from https://github.com/feross/fromentries/blob/29b52a850bb3a47c390937631c2638edf3443942/index.js
4
7
  export function fromEntries(iterable) {
5
8
  return [...iterable]
@@ -17,6 +20,14 @@ export function commaNumber(n) {
17
20
  export function capitalize(word) {
18
21
  return word ? word.charAt(0).toUpperCase() + word.slice(1) : '';
19
22
  }
23
+ /**
24
+ * Capitalize a the first letter of a string.
25
+ * @param {string} word A string to capitalize.
26
+ * @returns {string} The word parameter with the first letter capitalized.
27
+ */
28
+ export function pluralize(word, count = null) {
29
+ return plur(word, count);
30
+ }
20
31
  /**
21
32
  * Get the longest string in the array of strings.
22
33
  * @param {string[]} strings The array of strings.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/utils",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "author": "Gehlenborg Lab",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -19,7 +19,8 @@
19
19
  "bowser": "^2.11.0",
20
20
  "lodash-es": "^4.17.21",
21
21
  "lz-string": "^1.4.4",
22
- "@vitessce/sets-utils": "3.1.0"
22
+ "pluralize": "^8.0.0",
23
+ "@vitessce/sets-utils": "3.1.2"
23
24
  },
24
25
  "scripts": {
25
26
  "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
package/src/root.js CHANGED
@@ -1,5 +1,9 @@
1
1
  /* eslint-disable no-plusplus */
2
2
  // Originally in src/utils.js
3
+ import plur from 'pluralize';
4
+
5
+ plur.addPluralRule('glomerulus', 'glomeruli');
6
+ plur.addPluralRule('interstitium', 'interstitia');
3
7
 
4
8
  // Adapted from https://github.com/feross/fromentries/blob/29b52a850bb3a47c390937631c2638edf3443942/index.js
5
9
  export function fromEntries(iterable) {
@@ -21,6 +25,15 @@ export function capitalize(word) {
21
25
  return word ? word.charAt(0).toUpperCase() + word.slice(1) : '';
22
26
  }
23
27
 
28
+ /**
29
+ * Capitalize a the first letter of a string.
30
+ * @param {string} word A string to capitalize.
31
+ * @returns {string} The word parameter with the first letter capitalized.
32
+ */
33
+ export function pluralize(word, count = null) {
34
+ return plur(word, count);
35
+ }
36
+
24
37
  /**
25
38
  * Get the longest string in the array of strings.
26
39
  * @param {string[]} strings The array of strings.