@algolia/autocomplete-shared 1.2.2 → 1.5.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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare type UserAgent = {
2
+ segment: string;
3
+ version?: string;
4
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Decycles objects with circular references.
3
+ * This is used to print cyclic structures in development environment only.
4
+ */
5
+ export declare function decycle(obj: any, seen?: Set<unknown>): any;
@@ -0,0 +1,45 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
+
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
+
9
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
+
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+
13
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
14
+
15
+ /**
16
+ * Decycles objects with circular references.
17
+ * This is used to print cyclic structures in development environment only.
18
+ */
19
+ export function decycle(obj) {
20
+ var seen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Set();
21
+
22
+ if (!(process.env.NODE_ENV !== 'production') || !obj || _typeof(obj) !== 'object') {
23
+ return obj;
24
+ }
25
+
26
+ if (seen.has(obj)) {
27
+ return '[Circular]';
28
+ }
29
+
30
+ var newSeen = seen.add(obj);
31
+
32
+ if (Array.isArray(obj)) {
33
+ return obj.map(function (x) {
34
+ return decycle(x, newSeen);
35
+ });
36
+ }
37
+
38
+ return Object.fromEntries(Object.entries(obj).map(function (_ref) {
39
+ var _ref2 = _slicedToArray(_ref, 2),
40
+ key = _ref2[0],
41
+ value = _ref2[1];
42
+
43
+ return [key, decycle(value, newSeen)];
44
+ }));
45
+ }
@@ -0,0 +1 @@
1
+ export declare function flatten<TType>(values: Array<TType | TType[]>): TType[];
@@ -0,0 +1,5 @@
1
+ export function flatten(values) {
2
+ return values.reduce(function (a, b) {
3
+ return a.concat(b);
4
+ }, []);
5
+ }
@@ -1,9 +1,15 @@
1
1
  export * from './createRef';
2
2
  export * from './debounce';
3
+ export * from './decycle';
4
+ export * from './flatten';
3
5
  export * from './generateAutocompleteId';
4
6
  export * from './getAttributeValueByPath';
5
7
  export * from './getItemsCount';
6
8
  export * from './invariant';
7
9
  export * from './isEqual';
8
10
  export * from './MaybePromise';
11
+ export * from './noop';
12
+ export * from './UserAgent';
13
+ export * from './userAgents';
14
+ export * from './version';
9
15
  export * from './warn';
package/dist/esm/index.js CHANGED
@@ -1,9 +1,15 @@
1
1
  export * from './createRef';
2
2
  export * from './debounce';
3
+ export * from './decycle';
4
+ export * from './flatten';
3
5
  export * from './generateAutocompleteId';
4
6
  export * from './getAttributeValueByPath';
5
7
  export * from './getItemsCount';
6
8
  export * from './invariant';
7
9
  export * from './isEqual';
8
10
  export * from './MaybePromise';
11
+ export * from './noop';
12
+ export * from './UserAgent';
13
+ export * from './userAgents';
14
+ export * from './version';
9
15
  export * from './warn';
@@ -3,4 +3,4 @@
3
3
  * This is used to make development a better experience to provide guidance as
4
4
  * to where the error comes from.
5
5
  */
6
- export declare function invariant(condition: boolean, message: string): void;
6
+ export declare function invariant(condition: boolean, message: string | (() => string)): void;
@@ -9,6 +9,6 @@ export function invariant(condition, message) {
9
9
  }
10
10
 
11
11
  if (!condition) {
12
- throw new Error("[Autocomplete] ".concat(message));
12
+ throw new Error("[Autocomplete] ".concat(typeof message === 'function' ? message() : message));
13
13
  }
14
14
  }
@@ -0,0 +1 @@
1
+ export declare const noop: () => void;
@@ -0,0 +1 @@
1
+ export var noop = function noop() {};
@@ -0,0 +1,4 @@
1
+ export declare const userAgents: {
2
+ segment: string;
3
+ version: string;
4
+ }[];
@@ -0,0 +1,5 @@
1
+ import { version } from './version';
2
+ export var userAgents = [{
3
+ segment: 'autocomplete-core',
4
+ version: version
5
+ }];
@@ -0,0 +1 @@
1
+ export declare const version = "1.5.0";
@@ -0,0 +1 @@
1
+ export var version = '1.5.0';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@algolia/autocomplete-shared",
3
3
  "description": "Shared utils for Autocomplete packages.",
4
- "version": "1.2.2",
4
+ "version": "1.5.0",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/algolia/autocomplete",
7
7
  "repository": "algolia/autocomplete",