@takeshape/util 9.80.4 → 9.81.3

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.
Files changed (53) hide show
  1. package/dist/arrays.js +0 -10
  2. package/dist/async-noop.js +0 -2
  3. package/dist/billing.js +8 -4
  4. package/dist/browser.js +0 -2
  5. package/dist/clone.js +0 -1
  6. package/dist/common.js +0 -50
  7. package/dist/delay.js +3 -6
  8. package/dist/draftjs-templates.js +1 -11
  9. package/dist/draftjs.js +37 -196
  10. package/dist/encryption.js +2 -11
  11. package/dist/get-image-url.js +2 -3
  12. package/dist/gzip.js +0 -4
  13. package/dist/highlight-code.js +1 -19
  14. package/dist/http.js +0 -6
  15. package/dist/index.js +0 -8
  16. package/dist/map.js +0 -1
  17. package/dist/merge.js +3 -20
  18. package/dist/mime.js +4 -12
  19. package/dist/predicate.js +0 -3
  20. package/dist/search-params.js +0 -6
  21. package/dist/set-in.js +0 -2
  22. package/dist/sets.js +0 -5
  23. package/dist/sleep.js +0 -1
  24. package/dist/sort-object.js +4 -4
  25. package/dist/strings.js +4 -21
  26. package/dist/templates.js +1 -25
  27. package/dist/timezone.js +2 -4
  28. package/dist/types.js +8 -10
  29. package/dist/unix-to-iso.js +0 -2
  30. package/dist/value.js +0 -2
  31. package/dist/visit.js +1 -15
  32. package/es/arrays.js +0 -4
  33. package/es/billing.js +10 -0
  34. package/es/delay.js +3 -4
  35. package/es/draftjs-templates.js +1 -1
  36. package/es/draftjs.js +39 -173
  37. package/es/encryption.js +2 -3
  38. package/es/get-image-url.js +2 -1
  39. package/es/highlight-code.js +0 -1
  40. package/es/http.js +0 -4
  41. package/es/index.js +2 -2
  42. package/es/merge.js +4 -8
  43. package/es/mime.js +4 -5
  44. package/es/search-params.js +0 -2
  45. package/es/set-in.js +1 -1
  46. package/es/sets.js +0 -3
  47. package/es/sort-object.js +4 -2
  48. package/es/strings.js +4 -8
  49. package/es/templates.js +0 -14
  50. package/es/timezone.js +2 -2
  51. package/es/types.js +8 -3
  52. package/es/visit.js +1 -12
  53. package/package.json +3 -3
package/es/encryption.js CHANGED
@@ -14,12 +14,11 @@ export const encrypt = curry((key, plaintext) => {
14
14
  });
15
15
  export const decrypt = curry((key, encrypted) => {
16
16
  const input = Buffer.from(encrypted, CIPHER_TEXT_ENCODING);
17
-
18
17
  if (input.length < IV_LENGTH + 1) {
19
18
  throw new TypeError('Provided "encrypted" must decrypt to a non-empty string');
20
- } // Initialization Vector
21
-
19
+ }
22
20
 
21
+ // Initialization Vector
23
22
  const iv = input.slice(0, IV_LENGTH);
24
23
  const decipher = crypto.createDecipheriv(CIPHER_ALGORITHM, Buffer.from(key, KEY_ENCODING), iv);
25
24
  const cipherText = input.slice(IV_LENGTH);
@@ -1,6 +1,7 @@
1
1
  import { getImageUrl as imageUrl } from '@takeshape/routing';
2
2
  export function getImageUrl(path, defaultImageConfig, imageBaseUrl, config) {
3
- return imageUrl(path, { ...defaultImageConfig,
3
+ return imageUrl(path, {
4
+ ...defaultImageConfig,
4
5
  ...config
5
6
  }, {
6
7
  baseUrl: imageBaseUrl
@@ -22,6 +22,5 @@ export const highlightCode = (code, lang) => {
22
22
  const syntax = Prism.languages[lang];
23
23
  return Prism.highlight(code, syntax, lang);
24
24
  }
25
-
26
25
  return escape(code);
27
26
  };
package/es/http.js CHANGED
@@ -1,15 +1,11 @@
1
1
  export const getBasicAuthString = basicAuth => {
2
2
  let authString = '';
3
-
4
3
  if (basicAuth.username) {
5
4
  authString += basicAuth.username;
6
5
  }
7
-
8
6
  authString += ':';
9
-
10
7
  if (basicAuth.password) {
11
8
  authString += basicAuth.password;
12
9
  }
13
-
14
10
  return Buffer.from(authString).toString('base64');
15
11
  };
package/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export * from './common'; // Node-only exports
2
-
1
+ export * from './common';
2
+ // Node-only exports
3
3
  export * from './encryption';
4
4
  export * from './gzip';
5
5
  export * from './search-params';
package/es/merge.js CHANGED
@@ -6,39 +6,37 @@ import difference from 'lodash/difference';
6
6
  import omit from 'lodash/omit';
7
7
  import isEqual from 'lodash/isEqual';
8
8
  import union from 'lodash/union';
9
+
9
10
  /**
10
11
  * Lodash `mergeWith` customizer to concat arrays
11
12
  */
12
-
13
13
  const arrayConcatCustomizer = (value, srcValue) => {
14
14
  if (isArray(value)) {
15
15
  return value.concat(srcValue);
16
16
  }
17
17
  };
18
+
18
19
  /**
19
20
  * Lodash `mergeWith` loaded with a customizer that concatenates arrays for a
20
21
  * deeper merge.
21
22
  */
22
-
23
-
24
23
  export function mergeWithArrayConcat(object, source) {
25
24
  return mergeWith(object, source, arrayConcatCustomizer);
26
25
  }
26
+
27
27
  /**
28
28
  * Lodash `mergeWith` customizer to merge arrays
29
29
  */
30
-
31
30
  const arrayMergeCustomizer = (value, srcValue) => {
32
31
  if (isArray(value) && isArray(srcValue)) {
33
32
  return merge(value, srcValue).filter(val => !isNull(val));
34
33
  }
35
34
  };
35
+
36
36
  /**
37
37
  * Lodash `mergeWith` loaded with a customizer that merges arrays at the same
38
38
  * object path. Array items set to `null` will be removed.
39
39
  */
40
-
41
-
42
40
  export function mergeWithArrayMerge(object, source) {
43
41
  return mergeWith(object, source, arrayMergeCustomizer);
44
42
  }
@@ -46,13 +44,11 @@ export function rebaseObject(to, base, from) {
46
44
  const fromKeys = Object.keys(from);
47
45
  const removedKeys = difference(Object.keys(base), fromKeys);
48
46
  const newObj = omit(to, removedKeys);
49
-
50
47
  for (const key of fromKeys) {
51
48
  if (!isEqual(base[key], from[key])) {
52
49
  newObj[key] = from[key];
53
50
  }
54
51
  }
55
-
56
52
  return newObj;
57
53
  }
58
54
  export function rebaseArray(to, base, from) {
package/es/mime.js CHANGED
@@ -1,29 +1,28 @@
1
1
  import mime from 'mime-types';
2
- const compressedMimeTypes = new Set(['application/atom+xml', 'application/javascript', 'application/json', 'application/ld+json', 'application/manifest+json', 'application/rdf+xml', 'application/rss+xml', 'application/schema+json', 'application/vnd.geo+json', 'application/vnd.ms-fontobject', 'application/x-font-ttf', 'application/x-javascript', 'application/x-web-app-manifest+json', 'application/xhtml+xml', 'application/xml', 'font/eot', 'font/otf', 'font/opentype', 'image/bmp', 'image/svg+xml', 'image/vnd.microsoft.icon', 'image/x-icon', 'text/cache-manifest', 'text/css', 'text/html', 'text/javascript', 'text/plain', 'text/vcard', 'text/vnd.rim.location.xloc', 'text/vtt', 'text/x-component', 'text/x-cross-domain-policy', 'text/xml']); // Application/octetstream
2
+ const compressedMimeTypes = new Set(['application/atom+xml', 'application/javascript', 'application/json', 'application/ld+json', 'application/manifest+json', 'application/rdf+xml', 'application/rss+xml', 'application/schema+json', 'application/vnd.geo+json', 'application/vnd.ms-fontobject', 'application/x-font-ttf', 'application/x-javascript', 'application/x-web-app-manifest+json', 'application/xhtml+xml', 'application/xml', 'font/eot', 'font/otf', 'font/opentype', 'image/bmp', 'image/svg+xml', 'image/vnd.microsoft.icon', 'image/x-icon', 'text/cache-manifest', 'text/css', 'text/html', 'text/javascript', 'text/plain', 'text/vcard', 'text/vnd.rim.location.xloc', 'text/vtt', 'text/x-component', 'text/x-cross-domain-policy', 'text/xml']);
3
3
 
4
+ // Application/octetstream
4
5
  const DEFAULT_TYPE = mime.lookup('bin');
6
+
5
7
  /**
6
8
  * Gets the content type of the file, based on it's extension.
7
9
  * @param {String} src Path to file fow which content type should be evaluated.
8
10
  * @return {String} Returns string with content type and charset.
9
11
  */
10
-
11
12
  export function contentType(src) {
12
13
  let type = (mime.lookup(src) || DEFAULT_TYPE).replace('-', '');
13
14
  const charset = mime.charset(type);
14
-
15
15
  if (charset) {
16
16
  type += '; charset=' + charset;
17
17
  }
18
-
19
18
  return type;
20
19
  }
20
+
21
21
  /**
22
22
  * Determines whether we should compress based on file extension
23
23
  * @param {String} src Path to file fow which content type should be evaluated.
24
24
  * @return {Boolean} Returns true if we should compress
25
25
  */
26
-
27
26
  export function shouldCompress(src) {
28
27
  const mimeType = mime.lookup(src);
29
28
  return Boolean(mimeType && compressedMimeTypes.has(mimeType));
@@ -3,11 +3,9 @@ export function toSearchParamsEntries(obj) {
3
3
  if (obj instanceof URLSearchParams) {
4
4
  return [...obj.entries()];
5
5
  }
6
-
7
6
  if (typeof obj === 'object' && !Array.isArray(obj)) {
8
7
  return Object.entries(obj).map(([k, v]) => [k, (v === null || v === void 0 ? void 0 : v.toString()) ?? '']);
9
8
  }
10
-
11
9
  return [...new URLSearchParams(obj).entries()];
12
10
  }
13
11
  export function toSearchParamsRecord(obj) {
package/es/set-in.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { clone, setWith, curry } from 'lodash/fp';
2
+
2
3
  /**
3
4
  * Same as lodash/set but does not mutate the arguments
4
5
  */
5
-
6
6
  export const setIn = curry((obj, path, value) => setWith(clone, path, value, clone(obj)));
package/es/sets.js CHANGED
@@ -2,16 +2,13 @@ export function addAll(set, iterable) {
2
2
  for (const value of iterable) {
3
3
  set.add(value);
4
4
  }
5
-
6
5
  return set;
7
6
  }
8
7
  export function mapSet(set, fn) {
9
8
  const result = new Array(set.size);
10
9
  let i = 0;
11
-
12
10
  for (const value of set) {
13
11
  result[i++] = fn(value);
14
12
  }
15
-
16
13
  return result;
17
14
  }
package/es/sort-object.js CHANGED
@@ -4,9 +4,11 @@
4
4
  */
5
5
  export const sortObject = obj => {
6
6
  // Convert object to array of key-value pairs
7
- const arr = Object.entries(obj); // Sort array by key
7
+ const arr = Object.entries(obj);
8
8
 
9
- arr.sort(([key1], [key2]) => key1.localeCompare(key2)); // Convert array back to object
9
+ // Sort array by key
10
+ arr.sort(([key1], [key2]) => key1.localeCompare(key2));
10
11
 
12
+ // Convert array back to object
11
13
  return Object.fromEntries(arr);
12
14
  };
package/es/strings.js CHANGED
@@ -4,6 +4,7 @@ import isEmpty from 'lodash/isEmpty';
4
4
  import isString from 'lodash/isString';
5
5
  import { ensureArray } from './arrays';
6
6
  export const camelCase = _camelCase;
7
+
7
8
  /**
8
9
  * Special function for preserving namespace case when pascal-casing.
9
10
  */
@@ -11,37 +12,33 @@ export const camelCase = _camelCase;
11
12
  export function formatShapeName(str, options) {
12
13
  const strings = ensureArray(str);
13
14
  const shapeNameIndex = (options === null || options === void 0 ? void 0 : options.shapeNameIndex) ?? 0;
14
- const shapeName = strings.at(shapeNameIndex); // If the shapeNameIndex is incorrect, behave as normal
15
+ const shapeName = strings.at(shapeNameIndex);
15
16
 
17
+ // If the shapeNameIndex is incorrect, behave as normal
16
18
  if (!shapeName) {
17
19
  throw new Error(`Could not find a ShapeName at index '${shapeNameIndex}'`);
18
20
  }
19
-
20
21
  const prefix = strings.slice(0, Math.max(shapeNameIndex, 0));
21
22
  const suffix = strings.slice(shapeNameIndex + 1);
22
23
  let arr = [];
23
-
24
24
  if (prefix) {
25
25
  arr = [...arr, pascalCase(prefix)];
26
26
  }
27
-
28
27
  if (shapeName.length > 2 && shapeName.startsWith('TS') && shapeName.charAt(2) === shapeName.charAt(2).toUpperCase()) {
29
28
  // Built-in shape, prefixed with `TS`
30
29
  arr = [...arr, shapeName];
31
30
  } else {
32
31
  arr = [...arr, pascalCase(shapeName)];
33
32
  }
34
-
35
33
  if (suffix) {
36
34
  arr = [...arr, pascalCase(suffix)];
37
35
  }
38
-
39
36
  return arr.join('');
40
37
  }
38
+
41
39
  /**
42
40
  * Optional config triggers a namespace-preserving behavior for built-in shapes starting with `TS`.
43
41
  */
44
-
45
42
  export function pascalCase(str) {
46
43
  return upperFirst(camelCase(str));
47
44
  }
@@ -55,6 +52,5 @@ export function isIntegerLike(value) {
55
52
  if (typeof value === 'number') {
56
53
  return true;
57
54
  }
58
-
59
55
  return /^\d+$/.test(value);
60
56
  }
package/es/templates.js CHANGED
@@ -13,20 +13,16 @@ export function attrs(obj) {
13
13
  const attrStrings = [];
14
14
  const attrNames = Object.keys(obj);
15
15
  attrNames.sort();
16
-
17
16
  for (const attrName of attrNames) {
18
17
  const value = obj[attrName];
19
-
20
18
  if (value) {
21
19
  attrStrings.push(`${attrName}="${escape(value)}"`);
22
20
  }
23
21
  }
24
-
25
22
  return attrStrings.length ? ' ' + attrStrings.join(' ') : '';
26
23
  }
27
24
  export function imageTemplate(applyPrefix, data) {
28
25
  var _data$link;
29
-
30
26
  const {
31
27
  caption,
32
28
  credit,
@@ -35,20 +31,16 @@ export function imageTemplate(applyPrefix, data) {
35
31
  asset,
36
32
  imageParams
37
33
  } = data;
38
-
39
34
  if (!asset) {
40
35
  return '';
41
36
  }
42
-
43
37
  const imageUrl = getImageUrl(asset.path, imageParams);
44
38
  let figCaption = '';
45
-
46
39
  if (caption || credit) {
47
40
  const htmlCaption = caption ? `<span class="${applyPrefix('caption')}">${caption}</span>` : '';
48
41
  const htmlCredit = credit ? `<span class="${applyPrefix('credit')}">${credit}</span>` : '';
49
42
  figCaption = `<figcaption>${htmlCaption} ${htmlCredit}</figcaption>`;
50
43
  }
51
-
52
44
  const classes = classnames(applyPrefix(alignment), applyPrefix(size));
53
45
  const classAttr = classes ? ` class="${classes}"` : '';
54
46
  const imgAttrs = attrs({
@@ -56,27 +48,21 @@ export function imageTemplate(applyPrefix, data) {
56
48
  title: asset.title
57
49
  });
58
50
  let image = `<img${imgAttrs} src="${imageUrl}"/>`;
59
-
60
51
  if ((_data$link = data.link) !== null && _data$link !== void 0 && _data$link.url) {
61
52
  const target = data.link.external ? ' target="blank" rel="noopener noreferrer"' : '';
62
53
  image = `<a href="${data.link.url}"${target}>${image}</a>`;
63
54
  }
64
-
65
55
  return `<figure${classAttr}>${image}${figCaption}</figure>`;
66
56
  }
67
-
68
57
  function renderMdx(tag, attributes, data, children) {
69
58
  const tagWithAttributes = `${tag} ${attributes.map(attr => `${attr}="${escape(data[attr])}"`).join(' ')}`;
70
-
71
59
  if (children) {
72
60
  return `<${tagWithAttributes}>
73
61
  ${children.replace(/[\n\r]+$/, '')}
74
62
  </${tag}>`;
75
63
  }
76
-
77
64
  return `<${tagWithAttributes}/>`;
78
65
  }
79
-
80
66
  export function imageTemplateMdx(applyPrefix, data) {
81
67
  return renderMdx(applyPrefix('Image'), ['id', 'caption', 'credit', 'link', 'linkisexternal', 'alignment', 'size', 'src'], data);
82
68
  }
package/es/timezone.js CHANGED
@@ -3,8 +3,8 @@ export function guessTimeZone() {
3
3
  // eslint-disable-next-line new-cap
4
4
  return Intl.DateTimeFormat().resolvedOptions().timeZone;
5
5
  }
6
-
7
6
  return 'UTC';
8
- } // Equivalent to `moment.tz.names()`
7
+ }
9
8
 
9
+ // Equivalent to `moment.tz.names()`
10
10
  export const timeZoneList = ['Africa/Abidjan', 'Africa/Accra', 'Africa/Addis_Ababa', 'Africa/Algiers', 'Africa/Asmara', 'Africa/Asmera', 'Africa/Bamako', 'Africa/Bangui', 'Africa/Banjul', 'Africa/Bissau', 'Africa/Blantyre', 'Africa/Brazzaville', 'Africa/Bujumbura', 'Africa/Cairo', 'Africa/Casablanca', 'Africa/Ceuta', 'Africa/Conakry', 'Africa/Dakar', 'Africa/Dar_es_Salaam', 'Africa/Djibouti', 'Africa/Douala', 'Africa/El_Aaiun', 'Africa/Freetown', 'Africa/Gaborone', 'Africa/Harare', 'Africa/Johannesburg', 'Africa/Juba', 'Africa/Kampala', 'Africa/Khartoum', 'Africa/Kigali', 'Africa/Kinshasa', 'Africa/Lagos', 'Africa/Libreville', 'Africa/Lome', 'Africa/Luanda', 'Africa/Lubumbashi', 'Africa/Lusaka', 'Africa/Malabo', 'Africa/Maputo', 'Africa/Maseru', 'Africa/Mbabane', 'Africa/Mogadishu', 'Africa/Monrovia', 'Africa/Nairobi', 'Africa/Ndjamena', 'Africa/Niamey', 'Africa/Nouakchott', 'Africa/Ouagadougou', 'Africa/Porto-Novo', 'Africa/Sao_Tome', 'Africa/Timbuktu', 'Africa/Tripoli', 'Africa/Tunis', 'Africa/Windhoek', 'America/Adak', 'America/Anchorage', 'America/Anguilla', 'America/Antigua', 'America/Araguaina', 'America/Argentina/Buenos_Aires', 'America/Argentina/Catamarca', 'America/Argentina/ComodRivadavia', 'America/Argentina/Cordoba', 'America/Argentina/Jujuy', 'America/Argentina/La_Rioja', 'America/Argentina/Mendoza', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Salta', 'America/Argentina/San_Juan', 'America/Argentina/San_Luis', 'America/Argentina/Tucuman', 'America/Argentina/Ushuaia', 'America/Aruba', 'America/Asuncion', 'America/Atikokan', 'America/Atka', 'America/Bahia', 'America/Bahia_Banderas', 'America/Barbados', 'America/Belem', 'America/Belize', 'America/Blanc-Sablon', 'America/Boa_Vista', 'America/Bogota', 'America/Boise', 'America/Buenos_Aires', 'America/Cambridge_Bay', 'America/Campo_Grande', 'America/Cancun', 'America/Caracas', 'America/Catamarca', 'America/Cayenne', 'America/Cayman', 'America/Chicago', 'America/Chihuahua', 'America/Coral_Harbour', 'America/Cordoba', 'America/Costa_Rica', 'America/Creston', 'America/Cuiaba', 'America/Curacao', 'America/Danmarkshavn', 'America/Dawson', 'America/Dawson_Creek', 'America/Denver', 'America/Detroit', 'America/Dominica', 'America/Edmonton', 'America/Eirunepe', 'America/El_Salvador', 'America/Ensenada', 'America/Fort_Nelson', 'America/Fort_Wayne', 'America/Fortaleza', 'America/Glace_Bay', 'America/Godthab', 'America/Goose_Bay', 'America/Grand_Turk', 'America/Grenada', 'America/Guadeloupe', 'America/Guatemala', 'America/Guayaquil', 'America/Guyana', 'America/Halifax', 'America/Havana', 'America/Hermosillo', 'America/Indiana/Indianapolis', 'America/Indiana/Knox', 'America/Indiana/Marengo', 'America/Indiana/Petersburg', 'America/Indiana/Tell_City', 'America/Indiana/Vevay', 'America/Indiana/Vincennes', 'America/Indiana/Winamac', 'America/Indianapolis', 'America/Inuvik', 'America/Iqaluit', 'America/Jamaica', 'America/Jujuy', 'America/Juneau', 'America/Kentucky/Louisville', 'America/Kentucky/Monticello', 'America/Knox_IN', 'America/Kralendijk', 'America/La_Paz', 'America/Lima', 'America/Los_Angeles', 'America/Louisville', 'America/Lower_Princes', 'America/Maceio', 'America/Managua', 'America/Manaus', 'America/Marigot', 'America/Martinique', 'America/Matamoros', 'America/Mazatlan', 'America/Mendoza', 'America/Menominee', 'America/Merida', 'America/Metlakatla', 'America/Mexico_City', 'America/Miquelon', 'America/Moncton', 'America/Monterrey', 'America/Montevideo', 'America/Montreal', 'America/Montserrat', 'America/Nassau', 'America/New_York', 'America/Nipigon', 'America/Nome', 'America/Noronha', 'America/North_Dakota/Beulah', 'America/North_Dakota/Center', 'America/North_Dakota/New_Salem', 'America/Nuuk', 'America/Ojinaga', 'America/Panama', 'America/Pangnirtung', 'America/Paramaribo', 'America/Phoenix', 'America/Port-au-Prince', 'America/Port_of_Spain', 'America/Porto_Acre', 'America/Porto_Velho', 'America/Puerto_Rico', 'America/Punta_Arenas', 'America/Rainy_River', 'America/Rankin_Inlet', 'America/Recife', 'America/Regina', 'America/Resolute', 'America/Rio_Branco', 'America/Rosario', 'America/Santa_Isabel', 'America/Santarem', 'America/Santiago', 'America/Santo_Domingo', 'America/Sao_Paulo', 'America/Scoresbysund', 'America/Shiprock', 'America/Sitka', 'America/St_Barthelemy', 'America/St_Johns', 'America/St_Kitts', 'America/St_Lucia', 'America/St_Thomas', 'America/St_Vincent', 'America/Swift_Current', 'America/Tegucigalpa', 'America/Thule', 'America/Thunder_Bay', 'America/Tijuana', 'America/Toronto', 'America/Tortola', 'America/Vancouver', 'America/Virgin', 'America/Whitehorse', 'America/Winnipeg', 'America/Yakutat', 'America/Yellowknife', 'Antarctica/Casey', 'Antarctica/Davis', 'Antarctica/DumontDUrville', 'Antarctica/Macquarie', 'Antarctica/Mawson', 'Antarctica/McMurdo', 'Antarctica/Palmer', 'Antarctica/Rothera', 'Antarctica/South_Pole', 'Antarctica/Syowa', 'Antarctica/Troll', 'Antarctica/Vostok', 'Arctic/Longyearbyen', 'Asia/Aden', 'Asia/Almaty', 'Asia/Amman', 'Asia/Anadyr', 'Asia/Aqtau', 'Asia/Aqtobe', 'Asia/Ashgabat', 'Asia/Ashkhabad', 'Asia/Atyrau', 'Asia/Baghdad', 'Asia/Bahrain', 'Asia/Baku', 'Asia/Bangkok', 'Asia/Barnaul', 'Asia/Beirut', 'Asia/Bishkek', 'Asia/Brunei', 'Asia/Calcutta', 'Asia/Chita', 'Asia/Choibalsan', 'Asia/Chongqing', 'Asia/Chungking', 'Asia/Colombo', 'Asia/Dacca', 'Asia/Damascus', 'Asia/Dhaka', 'Asia/Dili', 'Asia/Dubai', 'Asia/Dushanbe', 'Asia/Famagusta', 'Asia/Gaza', 'Asia/Harbin', 'Asia/Hebron', 'Asia/Ho_Chi_Minh', 'Asia/Hong_Kong', 'Asia/Hovd', 'Asia/Irkutsk', 'Asia/Istanbul', 'Asia/Jakarta', 'Asia/Jayapura', 'Asia/Jerusalem', 'Asia/Kabul', 'Asia/Kamchatka', 'Asia/Karachi', 'Asia/Kashgar', 'Asia/Kathmandu', 'Asia/Katmandu', 'Asia/Khandyga', 'Asia/Kolkata', 'Asia/Krasnoyarsk', 'Asia/Kuala_Lumpur', 'Asia/Kuching', 'Asia/Kuwait', 'Asia/Macao', 'Asia/Macau', 'Asia/Magadan', 'Asia/Makassar', 'Asia/Manila', 'Asia/Muscat', 'Asia/Nicosia', 'Asia/Novokuznetsk', 'Asia/Novosibirsk', 'Asia/Omsk', 'Asia/Oral', 'Asia/Phnom_Penh', 'Asia/Pontianak', 'Asia/Pyongyang', 'Asia/Qatar', 'Asia/Qostanay', 'Asia/Qyzylorda', 'Asia/Rangoon', 'Asia/Riyadh', 'Asia/Saigon', 'Asia/Sakhalin', 'Asia/Samarkand', 'Asia/Seoul', 'Asia/Shanghai', 'Asia/Singapore', 'Asia/Srednekolymsk', 'Asia/Taipei', 'Asia/Tashkent', 'Asia/Tbilisi', 'Asia/Tehran', 'Asia/Tel_Aviv', 'Asia/Thimbu', 'Asia/Thimphu', 'Asia/Tokyo', 'Asia/Tomsk', 'Asia/Ujung_Pandang', 'Asia/Ulaanbaatar', 'Asia/Ulan_Bator', 'Asia/Urumqi', 'Asia/Ust-Nera', 'Asia/Vientiane', 'Asia/Vladivostok', 'Asia/Yakutsk', 'Asia/Yangon', 'Asia/Yekaterinburg', 'Asia/Yerevan', 'Atlantic/Azores', 'Atlantic/Bermuda', 'Atlantic/Canary', 'Atlantic/Cape_Verde', 'Atlantic/Faeroe', 'Atlantic/Faroe', 'Atlantic/Jan_Mayen', 'Atlantic/Madeira', 'Atlantic/Reykjavik', 'Atlantic/South_Georgia', 'Atlantic/St_Helena', 'Atlantic/Stanley', 'Australia/ACT', 'Australia/Adelaide', 'Australia/Brisbane', 'Australia/Broken_Hill', 'Australia/Canberra', 'Australia/Currie', 'Australia/Darwin', 'Australia/Eucla', 'Australia/Hobart', 'Australia/LHI', 'Australia/Lindeman', 'Australia/Lord_Howe', 'Australia/Melbourne', 'Australia/NSW', 'Australia/North', 'Australia/Perth', 'Australia/Queensland', 'Australia/South', 'Australia/Sydney', 'Australia/Tasmania', 'Australia/Victoria', 'Australia/West', 'Australia/Yancowinna', 'Brazil/Acre', 'Brazil/DeNoronha', 'Brazil/East', 'Brazil/West', 'CET', 'CST6CDT', 'Canada/Atlantic', 'Canada/Central', 'Canada/Eastern', 'Canada/Mountain', 'Canada/Newfoundland', 'Canada/Pacific', 'Canada/Saskatchewan', 'Canada/Yukon', 'Chile/Continental', 'Chile/EasterIsland', 'Cuba', 'EET', 'EST', 'EST5EDT', 'Egypt', 'Eire', 'Etc/GMT', 'Etc/GMT+0', 'Etc/GMT+1', 'Etc/GMT+10', 'Etc/GMT+11', 'Etc/GMT+12', 'Etc/GMT+2', 'Etc/GMT+3', 'Etc/GMT+4', 'Etc/GMT+5', 'Etc/GMT+6', 'Etc/GMT+7', 'Etc/GMT+8', 'Etc/GMT+9', 'Etc/GMT-0', 'Etc/GMT-1', 'Etc/GMT-10', 'Etc/GMT-11', 'Etc/GMT-12', 'Etc/GMT-13', 'Etc/GMT-14', 'Etc/GMT-2', 'Etc/GMT-3', 'Etc/GMT-4', 'Etc/GMT-5', 'Etc/GMT-6', 'Etc/GMT-7', 'Etc/GMT-8', 'Etc/GMT-9', 'Etc/GMT0', 'Etc/Greenwich', 'Etc/UCT', 'Etc/UTC', 'Etc/Universal', 'Etc/Zulu', 'Europe/Amsterdam', 'Europe/Andorra', 'Europe/Astrakhan', 'Europe/Athens', 'Europe/Belfast', 'Europe/Belgrade', 'Europe/Berlin', 'Europe/Bratislava', 'Europe/Brussels', 'Europe/Bucharest', 'Europe/Budapest', 'Europe/Busingen', 'Europe/Chisinau', 'Europe/Copenhagen', 'Europe/Dublin', 'Europe/Gibraltar', 'Europe/Guernsey', 'Europe/Helsinki', 'Europe/Isle_of_Man', 'Europe/Istanbul', 'Europe/Jersey', 'Europe/Kaliningrad', 'Europe/Kiev', 'Europe/Kirov', 'Europe/Lisbon', 'Europe/Ljubljana', 'Europe/London', 'Europe/Luxembourg', 'Europe/Madrid', 'Europe/Malta', 'Europe/Mariehamn', 'Europe/Minsk', 'Europe/Monaco', 'Europe/Moscow', 'Europe/Nicosia', 'Europe/Oslo', 'Europe/Paris', 'Europe/Podgorica', 'Europe/Prague', 'Europe/Riga', 'Europe/Rome', 'Europe/Samara', 'Europe/San_Marino', 'Europe/Sarajevo', 'Europe/Saratov', 'Europe/Simferopol', 'Europe/Skopje', 'Europe/Sofia', 'Europe/Stockholm', 'Europe/Tallinn', 'Europe/Tirane', 'Europe/Tiraspol', 'Europe/Ulyanovsk', 'Europe/Uzhgorod', 'Europe/Vaduz', 'Europe/Vatican', 'Europe/Vienna', 'Europe/Vilnius', 'Europe/Volgograd', 'Europe/Warsaw', 'Europe/Zagreb', 'Europe/Zaporozhye', 'Europe/Zurich', 'GB', 'GB-Eire', 'GMT', 'GMT+0', 'GMT-0', 'GMT0', 'Greenwich', 'HST', 'Hongkong', 'Iceland', 'Indian/Antananarivo', 'Indian/Chagos', 'Indian/Christmas', 'Indian/Cocos', 'Indian/Comoro', 'Indian/Kerguelen', 'Indian/Mahe', 'Indian/Maldives', 'Indian/Mauritius', 'Indian/Mayotte', 'Indian/Reunion', 'Iran', 'Israel', 'Jamaica', 'Japan', 'Kwajalein', 'Libya', 'MET', 'MST', 'MST7MDT', 'Mexico/BajaNorte', 'Mexico/BajaSur', 'Mexico/General', 'NZ', 'NZ-CHAT', 'Navajo', 'PRC', 'PST8PDT', 'Pacific/Apia', 'Pacific/Auckland', 'Pacific/Bougainville', 'Pacific/Chatham', 'Pacific/Chuuk', 'Pacific/Easter', 'Pacific/Efate', 'Pacific/Enderbury', 'Pacific/Fakaofo', 'Pacific/Fiji', 'Pacific/Funafuti', 'Pacific/Galapagos', 'Pacific/Gambier', 'Pacific/Guadalcanal', 'Pacific/Guam', 'Pacific/Honolulu', 'Pacific/Johnston', 'Pacific/Kiritimati', 'Pacific/Kosrae', 'Pacific/Kwajalein', 'Pacific/Majuro', 'Pacific/Marquesas', 'Pacific/Midway', 'Pacific/Nauru', 'Pacific/Niue', 'Pacific/Norfolk', 'Pacific/Noumea', 'Pacific/Pago_Pago', 'Pacific/Palau', 'Pacific/Pitcairn', 'Pacific/Pohnpei', 'Pacific/Ponape', 'Pacific/Port_Moresby', 'Pacific/Rarotonga', 'Pacific/Saipan', 'Pacific/Samoa', 'Pacific/Tahiti', 'Pacific/Tarawa', 'Pacific/Tongatapu', 'Pacific/Truk', 'Pacific/Wake', 'Pacific/Wallis', 'Pacific/Yap', 'Poland', 'Portugal', 'ROC', 'ROK', 'Singapore', 'Turkey', 'UCT', 'US/Alaska', 'US/Aleutian', 'US/Arizona', 'US/Central', 'US/East-Indiana', 'US/Eastern', 'US/Hawaii', 'US/Indiana-Starke', 'US/Michigan', 'US/Mountain', 'US/Pacific', 'US/Samoa', 'UTC', 'Universal', 'W-SU', 'WET', 'Zulu'];
package/es/types.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import isNull from 'lodash/isNull';
2
2
  import isPlainObject from 'lodash/isPlainObject';
3
-
4
3
  /**
5
4
  * A guard for objects that ensures they are plain objects, and thus, can
6
5
  * reasonably be typed as a Record.
@@ -9,6 +8,13 @@ export function isRecord(maybeRecord) {
9
8
  return isPlainObject(maybeRecord);
10
9
  }
11
10
 
11
+ // https://stackoverflow.com/questions/50573891/maybe-a-type-in-typescript
12
+
13
+ /**
14
+ * Type util migrated from schema package. Not currently used, but certain to
15
+ * be useful.
16
+ */
17
+
12
18
  /**
13
19
  * Create enum matchers, which will return the enum entry from the provided
14
20
  * enum when the value matches.
@@ -26,13 +32,12 @@ export function getSingle(t) {
26
32
  if (Array.isArray(t)) {
27
33
  return t[0];
28
34
  }
29
-
30
35
  return t;
31
36
  }
37
+
32
38
  /**
33
39
  * Test whether a provided string is numeric, e.g., '9' is numeric while 'nine' is not.
34
40
  */
35
-
36
41
  export function isNumericString(key) {
37
42
  return !isNaN(Number(key));
38
43
  }
package/es/visit.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import isObject from 'lodash/isObject';
2
-
3
2
  /**
4
3
  * Walk a tree, calling the callback for any property name matching a value in the keys array.
5
4
  */
@@ -9,56 +8,46 @@ export function visit(tree, keys, callback) {
9
8
  if (keys.includes(key)) {
10
9
  callback(value, [...path, key]);
11
10
  }
12
-
13
11
  if (isObject(value)) {
14
12
  traverse(value, [...path, key]);
15
13
  }
16
14
  }
17
15
  };
18
-
19
16
  traverse(tree, []);
20
17
  }
18
+
21
19
  /**
22
20
  * Walk a tree with JSONPath, calling the callback for matching properties.
23
21
  * Normalizes the resulting path
24
22
  */
25
-
26
23
  export function visitJsonPath(tree, jsonPaths, callback) {
27
24
  const paths = jsonPaths.map(p => p.split('.').slice());
28
-
29
25
  const testPaths = propPath => {
30
26
  return paths.findIndex(testPath => {
31
27
  const isFromRoot = testPath[0] === '$';
32
28
  const tPath = isFromRoot ? testPath.slice(1) : testPath.slice().reverse();
33
29
  const pPath = isFromRoot ? propPath.slice() : propPath.slice().reverse();
34
30
  let isMatchingPath = isFromRoot ? tPath.length === pPath.length : tPath.length <= pPath.length;
35
-
36
31
  for (const [pI, pP] of pPath.entries()) {
37
32
  if (tPath[pI] === undefined || !isMatchingPath) {
38
33
  break;
39
34
  }
40
-
41
35
  isMatchingPath = pP === tPath[pI] || tPath[pI] === '*';
42
36
  }
43
-
44
37
  return isMatchingPath;
45
38
  });
46
39
  };
47
-
48
40
  const traverse = (obj, path) => {
49
41
  for (const [prop, value] of Object.entries(obj)) {
50
42
  const propPath = [...path, prop];
51
43
  const foundIndex = testPaths(propPath);
52
-
53
44
  if (foundIndex > -1) {
54
45
  callback(value, propPath, foundIndex);
55
46
  }
56
-
57
47
  if (isObject(value)) {
58
48
  traverse(value, propPath);
59
49
  }
60
50
  }
61
51
  };
62
-
63
52
  traverse(tree, []);
64
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeshape/util",
3
- "version": "9.80.4",
3
+ "version": "9.81.3",
4
4
  "description": "Shared utilities",
5
5
  "homepage": "https://www.takeshape.io",
6
6
  "repository": {
@@ -33,7 +33,7 @@
33
33
  "shortid": "^2.2.16",
34
34
  "tiny-invariant": "^1.2.0",
35
35
  "url-parse": "^1.5.3",
36
- "@takeshape/routing": "9.80.4"
36
+ "@takeshape/routing": "9.81.3"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/classnames": "^2.2.9",
@@ -46,7 +46,7 @@
46
46
  "@types/prismjs": "^1.16.2",
47
47
  "@types/shortid": "^0.0.29",
48
48
  "stripe": "13.8.0",
49
- "@takeshape/typescript-jest-junit-reporter": "9.80.4"
49
+ "@takeshape/typescript-jest-junit-reporter": "9.81.3"
50
50
  },
51
51
  "engines": {
52
52
  "node": ">=16"