@furystack/utils 1.2.45 → 2.0.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 (44) hide show
  1. package/dist/index.d.ts +0 -2
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +0 -2
  4. package/dist/index.js.map +1 -1
  5. package/dist/path-helper.d.ts +1 -36
  6. package/dist/path-helper.d.ts.map +1 -1
  7. package/dist/path-helper.js +2 -73
  8. package/dist/path-helper.js.map +1 -1
  9. package/dist/path-helper.spec.d.ts.map +1 -1
  10. package/dist/path-helper.spec.js +2 -82
  11. package/dist/path-helper.spec.js.map +1 -1
  12. package/dist/value-observer.d.ts +1 -1
  13. package/dist/value-observer.d.ts.map +1 -1
  14. package/dist/value-observer.js.map +1 -1
  15. package/package.json +3 -3
  16. package/src/index.ts +0 -2
  17. package/src/path-helper.spec.ts +2 -101
  18. package/src/path-helper.ts +2 -77
  19. package/src/value-observer.ts +1 -1
  20. package/dist/filter-async.d.ts +0 -20
  21. package/dist/filter-async.d.ts.map +0 -1
  22. package/dist/filter-async.js +0 -23
  23. package/dist/filter-async.js.map +0 -1
  24. package/dist/filter-async.spec.d.ts +0 -2
  25. package/dist/filter-async.spec.d.ts.map +0 -1
  26. package/dist/filter-async.spec.js +0 -25
  27. package/dist/filter-async.spec.js.map +0 -1
  28. package/dist/retrier-options.d.ts +0 -50
  29. package/dist/retrier-options.d.ts.map +0 -1
  30. package/dist/retrier-options.js +0 -54
  31. package/dist/retrier-options.js.map +0 -1
  32. package/dist/retrier.d.ts +0 -52
  33. package/dist/retrier.d.ts.map +0 -1
  34. package/dist/retrier.js +0 -103
  35. package/dist/retrier.js.map +0 -1
  36. package/dist/retries.spec.d.ts +0 -5
  37. package/dist/retries.spec.d.ts.map +0 -1
  38. package/dist/retries.spec.js +0 -93
  39. package/dist/retries.spec.js.map +0 -1
  40. package/src/filter-async.spec.ts +0 -25
  41. package/src/filter-async.ts +0 -29
  42. package/src/retrier-options.ts +0 -65
  43. package/src/retrier.ts +0 -105
  44. package/src/retries.spec.ts +0 -98
package/dist/index.d.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  export * from './disposable';
2
2
  export * from './deep-merge';
3
- export * from './filter-async';
4
3
  export * from './debounce';
5
4
  export * from './observable-value';
6
- export * from './retrier';
7
5
  export * from './value-observer';
8
6
  export * from './path-helper';
9
7
  export * from './sleep-async';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
package/dist/index.js CHANGED
@@ -3,10 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  (0, tslib_1.__exportStar)(require("./disposable"), exports);
5
5
  (0, tslib_1.__exportStar)(require("./deep-merge"), exports);
6
- (0, tslib_1.__exportStar)(require("./filter-async"), exports);
7
6
  (0, tslib_1.__exportStar)(require("./debounce"), exports);
8
7
  (0, tslib_1.__exportStar)(require("./observable-value"), exports);
9
- (0, tslib_1.__exportStar)(require("./retrier"), exports);
10
8
  (0, tslib_1.__exportStar)(require("./value-observer"), exports);
11
9
  (0, tslib_1.__exportStar)(require("./path-helper"), exports);
12
10
  (0, tslib_1.__exportStar)(require("./sleep-async"), exports);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,4DAA4B;AAC5B,4DAA4B;AAC5B,8DAA8B;AAC9B,0DAA0B;AAC1B,kEAAkC;AAClC,yDAAyB;AACzB,gEAAgC;AAChC,6DAA6B;AAC7B,6DAA6B;AAC7B,yDAAyB;AACzB,uDAAuB;AACvB,uDAAuB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,4DAA4B;AAC5B,4DAA4B;AAC5B,0DAA0B;AAC1B,kEAAkC;AAClC,gEAAgC;AAChC,6DAA6B;AAC7B,6DAA6B;AAC7B,yDAAyB;AACzB,uDAAuB;AACvB,uDAAuB"}
@@ -13,47 +13,12 @@ export declare class PathHelper {
13
13
  static trimSlashes(path: string): string;
14
14
  /**
15
15
  * Splits a full path into path segments,
16
- * e.g.: /Root/Example('Content1') will be ["Root", "Example", "('Content1')"]
16
+ * e.g.: /Root/Example/stuff
17
17
  *
18
18
  * @param path The path to be splitted
19
19
  * @returns {string[]} the segments for the path
20
20
  */
21
21
  static getSegments(path: string): string[];
22
- /**
23
- * Checks if a specific segment is an Item segment or not (like "('Content1')"" or "(654)")
24
- *
25
- * @param segment The segment to be examined
26
- * @returns a boolean value that indicates if the segment is an item segment
27
- */
28
- static isItemSegment(segment: string): boolean;
29
- /**
30
- * Method that tells if a path is an item path or an item reference path (e.g. contains an Item segment).
31
- *
32
- * @param {string} path Path that you want to test.
33
- * @returns {boolean} Returns if the given path is a path of a Content or not.
34
- */
35
- static isItemPath(path: string): boolean;
36
- /**
37
- * Returns the full path for a content based on its Id or Path
38
- *
39
- * @param {string | number} idOrPath the Id Or Path of the content
40
- * @returns A full Id or Path-based url of the content (e.g. *'/content(1)'* or *'/Root/Example/('Content')'*)
41
- */
42
- static getContentUrl(idOrPath: string | number): string;
43
- /**
44
- * Method that gets the URL that refers to a single item in the Sense/Net Content Repository
45
- *
46
- * @param {string} path Path that you want to format.
47
- * @returns {string} Path in entity format e.g. /workspaces('project') from /workspaces/project
48
- */
49
- static getContentUrlByPath(path: string): string;
50
- /**
51
- * Method that gets the URL that refers to a single item in the Sense/Net Content Repository by its Id
52
- *
53
- * @param id {number} Id of the Content.
54
- * @returns {string} e.g. /content(123)
55
- */
56
- static getContentUrlbyId(id: number): string;
57
22
  /**
58
23
  * Method that allows to join paths without multiple or missing slashes
59
24
  *
@@ -1 +1 @@
1
- {"version":3,"file":"path-helper.d.ts","sourceRoot":"","sources":["../src/path-helper.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,UAAU;IACrB;;;;;OAKG;WACW,WAAW,CAAC,IAAI,EAAE,MAAM;IAUtC;;;;;;OAMG;WACW,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;IAcjD;;;;;OAKG;WACW,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAIrD;;;;;OAKG;WACW,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAM/C;;;;;OAKG;WACW,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IAS9D;;;;;OAKG;WACW,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAYvD;;;;;OAKG;WACW,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAInD;;;;;OAKG;WACW,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE;IAIzC;;;;;;OAMG;WACW,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO;IAIjF;;;;;;;;OAQG;WACW,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;WAQnC,SAAS,CAAC,IAAI,EAAE,MAAM;CAGrC"}
1
+ {"version":3,"file":"path-helper.d.ts","sourceRoot":"","sources":["../src/path-helper.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,UAAU;IACrB;;;;;OAKG;WACW,WAAW,CAAC,IAAI,EAAE,MAAM;IAUtC;;;;;;OAMG;WACW,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;IAIjD;;;;;OAKG;WACW,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE;IAIzC;;;;;;OAMG;WACW,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO;IAIjF;;;;;;;;OAQG;WACW,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;WAQnC,SAAS,CAAC,IAAI,EAAE,MAAM;CAGrC"}
@@ -24,84 +24,13 @@ class PathHelper {
24
24
  }
25
25
  /**
26
26
  * Splits a full path into path segments,
27
- * e.g.: /Root/Example('Content1') will be ["Root", "Example", "('Content1')"]
27
+ * e.g.: /Root/Example/stuff
28
28
  *
29
29
  * @param path The path to be splitted
30
30
  * @returns {string[]} the segments for the path
31
31
  */
32
32
  static getSegments(path) {
33
- return path
34
- .split(/\/|[(][']|[(]/g)
35
- .filter((segment) => segment && segment.length)
36
- .map((segment) => {
37
- if (segment.endsWith("')")) {
38
- segment = `('${segment}`;
39
- }
40
- else if (segment.endsWith(')')) {
41
- segment = `(${segment}`;
42
- }
43
- return segment;
44
- });
45
- }
46
- /**
47
- * Checks if a specific segment is an Item segment or not (like "('Content1')"" or "(654)")
48
- *
49
- * @param segment The segment to be examined
50
- * @returns a boolean value that indicates if the segment is an item segment
51
- */
52
- static isItemSegment(segment) {
53
- return RegExp(/^\('+[\s\S]+'\)$/).test(segment) || RegExp(/^\(+\d+\)$/).test(segment);
54
- }
55
- /**
56
- * Method that tells if a path is an item path or an item reference path (e.g. contains an Item segment).
57
- *
58
- * @param {string} path Path that you want to test.
59
- * @returns {boolean} Returns if the given path is a path of a Content or not.
60
- */
61
- static isItemPath(path) {
62
- const segments = this.getSegments(path);
63
- const itemSegment = segments.find((s) => this.isItemSegment(s));
64
- return itemSegment && itemSegment.length ? true : false;
65
- }
66
- /**
67
- * Returns the full path for a content based on its Id or Path
68
- *
69
- * @param {string | number} idOrPath the Id Or Path of the content
70
- * @returns A full Id or Path-based url of the content (e.g. *'/content(1)'* or *'/Root/Example/('Content')'*)
71
- */
72
- static getContentUrl(idOrPath) {
73
- const parsed = parseInt(idOrPath, 10);
74
- if (isNaN(parsed)) {
75
- return this.getContentUrlByPath(idOrPath.toString());
76
- }
77
- else {
78
- return this.getContentUrlbyId(parsed);
79
- }
80
- }
81
- /**
82
- * Method that gets the URL that refers to a single item in the Sense/Net Content Repository
83
- *
84
- * @param {string} path Path that you want to format.
85
- * @returns {string} Path in entity format e.g. /workspaces('project') from /workspaces/project
86
- */
87
- static getContentUrlByPath(path) {
88
- if (!path) {
89
- throw Error('Path is empty');
90
- }
91
- const segments = this.getSegments(path);
92
- if (!this.isItemPath(path)) {
93
- segments[segments.length - 1] = `('${segments[segments.length - 1]}')`;
94
- }
95
- return segments.join('/');
96
- }
97
- /**
98
- * Method that gets the URL that refers to a single item in the Sense/Net Content Repository by its Id
99
- *
100
- * @param id {number} Id of the Content.
101
- * @returns {string} e.g. /content(123)
102
- */
103
- static getContentUrlbyId(id) {
104
- return `content(${id})`;
33
+ return path.split('/').filter((segment) => segment && segment.length);
105
34
  }
106
35
  /**
107
36
  * Method that allows to join paths without multiple or missing slashes
@@ -1 +1 @@
1
- {"version":3,"file":"path-helper.js","sourceRoot":"","sources":["../src/path-helper.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,MAAa,UAAU;IACrB;;;;;OAKG;IACI,MAAM,CAAC,WAAW,CAAC,IAAY;QACpC,OAAO,IAAI,CA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OAAO,CAAC,MAAM,CAAC,CAAA;IACvE,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,SAAS,CAAC,GAAG,IAAc;QACvC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC7C,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,YAAY,CAAC,YAAoB,EAAE,cAAsB;QACrE,OAAO,cAAc,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IACzE,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,aAAa,CAAC,IAAY;QACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;QACvC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;YACvB,QAAQ,CAAC,GAAG,EAAE,CAAA;SACf;QACD,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC3B,CAAC;IAEM,MAAM,CAAC,SAAS,CAAC,IAAY;QAClC,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACzC,CAAC;CACF;AArED,gCAqEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"path-helper.spec.d.ts","sourceRoot":"","sources":["../src/path-helper.spec.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,eAAe,MAoK1B,CAAA"}
1
+ {"version":3,"file":"path-helper.spec.d.ts","sourceRoot":"","sources":["../src/path-helper.spec.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,eAAe,MAiE1B,CAAA"}
@@ -6,26 +6,6 @@ const path_helper_1 = require("./path-helper");
6
6
  * Path Helper tests
7
7
  */
8
8
  exports.pathHelperTests = describe('PathHelper', () => {
9
- describe('#isItemSegment()', () => {
10
- it('Should return true for item segments with string key "(\'Item1\')"', () => {
11
- expect(path_helper_1.PathHelper.isItemSegment("('Item1')")).toBe(true);
12
- });
13
- it('Should return true for item segments with numeric key "(42)"', () => {
14
- expect(path_helper_1.PathHelper.isItemSegment('(42)')).toBe(true);
15
- });
16
- it('Should return false for string keys w/o quotes', () => {
17
- expect(path_helper_1.PathHelper.isItemSegment('(invalidValue)')).toBe(false);
18
- });
19
- it('Should return false for invalid string keys', () => {
20
- expect(path_helper_1.PathHelper.isItemSegment('(123invalidValue)')).toBe(false);
21
- });
22
- it('Should return false for non-item segments', () => {
23
- expect(path_helper_1.PathHelper.isItemSegment('Item1')).toBe(false);
24
- });
25
- it('Should return false for inconsistent quotation', () => {
26
- expect(path_helper_1.PathHelper.isItemSegment("('123invalidValue)")).toBe(false);
27
- });
28
- });
29
9
  describe('#trimSlashes()', () => {
30
10
  it('should trim from the beginning of the segment', () => {
31
11
  expect(path_helper_1.PathHelper.trimSlashes('/segment')).toBe('segment');
@@ -40,63 +20,6 @@ exports.pathHelperTests = describe('PathHelper', () => {
40
20
  expect(path_helper_1.PathHelper.trimSlashes('segment///')).toBe('segment');
41
21
  });
42
22
  });
43
- describe('#isItemPath()', () => {
44
- it('should return true for item paths', () => {
45
- const isAnItem = path_helper_1.PathHelper.isItemPath("/workspace('project')");
46
- expect(isAnItem).toBe(true);
47
- });
48
- it('should return false for collection paths', () => {
49
- const isNotAnItem = path_helper_1.PathHelper.isItemPath('/workspace/project');
50
- expect(isNotAnItem).toBe(false);
51
- });
52
- it('should return true for reference paths', () => {
53
- const isAnItem = path_helper_1.PathHelper.isItemPath("/workspace/('project')/CustomAction");
54
- expect(isAnItem).toBe(true);
55
- });
56
- it('should return true for reference paths with ids', () => {
57
- const isAnItem = path_helper_1.PathHelper.isItemPath('/workspaces/(22)/CustomAction');
58
- expect(isAnItem).toBe(true);
59
- });
60
- });
61
- describe('#getContentUrlbyId()', () => {
62
- it('should return by path if the provided value is a path', () => {
63
- const url = path_helper_1.PathHelper.getContentUrl('/workspace/project');
64
- expect(url).toBe("workspace/('project')");
65
- });
66
- it('should return by id if the provided value is id', () => {
67
- const contentUrl = path_helper_1.PathHelper.getContentUrl(1);
68
- expect(contentUrl).toBe('content(1)');
69
- });
70
- });
71
- describe('#getContentUrlbyId()', () => {
72
- it('should create the path with the correct format', () => {
73
- const contentUrl = path_helper_1.PathHelper.getContentUrlbyId(1);
74
- expect(contentUrl).toBe('content(1)');
75
- });
76
- });
77
- describe('#getContentUrlByPath()', () => {
78
- it('should return a proper item path by the given path', () => {
79
- const contentUrl = path_helper_1.PathHelper.getContentUrlByPath('/workspace/project');
80
- expect(contentUrl).toBe("workspace/('project')");
81
- });
82
- it('should return the path itself if it is an item path already', () => {
83
- const contentUrl = path_helper_1.PathHelper.getContentUrlByPath("/workspace('project')");
84
- expect(contentUrl).toBe("workspace/('project')");
85
- });
86
- it('should return the path itself for reference paths', () => {
87
- const contentUrl = path_helper_1.PathHelper.getContentUrlByPath("/workspace('project')/Owner");
88
- expect(contentUrl).toBe("workspace/('project')/Owner");
89
- });
90
- it('should return an error message if the given argument is an empty string', () => {
91
- expect(() => {
92
- path_helper_1.PathHelper.getContentUrlByPath('');
93
- }).toThrow();
94
- });
95
- it('should return a proper item path for Root only', () => {
96
- const path = path_helper_1.PathHelper.getContentUrlByPath('/Root');
97
- expect(path).toBe("('Root')");
98
- });
99
- });
100
23
  describe('#joinPaths()', () => {
101
24
  it('should join with slashes', () => {
102
25
  const joined = path_helper_1.PathHelper.joinPaths('path1', 'path2', 'path3');
@@ -124,16 +47,13 @@ exports.pathHelperTests = describe('PathHelper', () => {
124
47
  });
125
48
  describe('#getSegments()', () => {
126
49
  it('Should split the path to segments', () => {
127
- expect(path_helper_1.PathHelper.getSegments("Root/Example('Content1')")).toEqual(['Root', 'Example', "('Content1')"]);
50
+ expect(path_helper_1.PathHelper.getSegments("Root/Example/('Content1')")).toEqual(['Root', 'Example', "('Content1')"]);
128
51
  });
129
52
  });
130
53
  describe('#getParentPath()', () => {
131
- it('Should return the parent path in case of more than 1 segments', () => {
54
+ it('Should return the parent path', () => {
132
55
  expect(path_helper_1.PathHelper.getParentPath('Root/Example/Content')).toBe('Root/Example');
133
56
  });
134
- it('Should return the parent path in case of more than 1 segments with item path', () => {
135
- expect(path_helper_1.PathHelper.getParentPath("Root/Example('Content')")).toBe('Root/Example');
136
- });
137
57
  it('Should return the path in case of 1 segments', () => {
138
58
  expect(path_helper_1.PathHelper.getParentPath('Root')).toBe('Root');
139
59
  });
@@ -1 +1 @@
1
- {"version":3,"file":"path-helper.spec.js","sourceRoot":"","sources":["../src/path-helper.spec.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAE1C;;GAEG;AACU,QAAA,eAAe,GAAG,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IACzD,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,EAAE,CAAC,oEAAoE,EAAE,GAAG,EAAE;YAC5E,MAAM,CAAC,wBAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC1D,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;YACtE,MAAM,CAAC,wBAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACrD,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;YACxD,MAAM,CAAC,wBAAU,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAChE,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;YACrD,MAAM,CAAC,wBAAU,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACnE,CAAC,CAAC,CAAA;QAEF,EAAE,CA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C,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;YACvC,MAAM,CAAC,wBAAU,CAAC,aAAa,CAAC,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;QAC/E,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;YACtD,MAAM,CAAC,wBAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACvD,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -24,7 +24,7 @@ import { ObservableValue, ValueChangeCallback } from './observable-value';
24
24
  * @param T This type parameter is the value type to observe
25
25
  */
26
26
  export declare class ValueObserver<T> implements Disposable {
27
- private readonly observable;
27
+ readonly observable: ObservableValue<T>;
28
28
  callback: ValueChangeCallback<T>;
29
29
  /**
30
30
  * Disposes the ValueObserver instance. Unsubscribes from the observable
@@ -1 +1 @@
1
- {"version":3,"file":"value-observer.d.ts","sourceRoot":"","sources":["../src/value-observer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAEzE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,UAAU;IAarC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAA6B,QAAQ,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAZpG;;OAEG;IACI,OAAO;IAId;;;;OAIG;gBAC0B,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC,EAAS,QAAQ,EAAE,mBAAmB,CAAC,CAAC,CAAC;CACrG"}
1
+ {"version":3,"file":"value-observer.d.ts","sourceRoot":"","sources":["../src/value-observer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAEzE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,UAAU;aAarB,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC;IAAS,QAAQ,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAZnG;;OAEG;IACI,OAAO;IAId;;;;OAIG;gBACyB,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC,EAAS,QAAQ,EAAE,mBAAmB,CAAC,CAAC,CAAC;CACpG"}
@@ -1 +1 @@
1
- {"version":3,"file":"value-observer.js","sourceRoot":"","sources":["../src/value-observer.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAa,aAAa;IAQxB;;;;OAIG;IACH,YAA6B,UAA8B,EAAS,QAAgC;QAAvE,eAAU,GAAV,UAAU,CAAoB;QAAS,aAAQ,GAAR,QAAQ,CAAwB;IAAG,CAAC;IAZxG;;OAEG;IACI,OAAO;QACZ,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;IACnC,CAAC;CAQF;AAdD,sCAcC"}
1
+ {"version":3,"file":"value-observer.js","sourceRoot":"","sources":["../src/value-observer.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAa,aAAa;IAQxB;;;;OAIG;IACH,YAA4B,UAA8B,EAAS,QAAgC;QAAvE,eAAU,GAAV,UAAU,CAAoB;QAAS,aAAQ,GAAR,QAAQ,CAAwB;IAAG,CAAC;IAZvG;;OAEG;IACI,OAAO;QACZ,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;IACnC,CAAC;CAQF;AAdD,sCAcC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@furystack/utils",
3
- "version": "1.2.45",
3
+ "version": "2.0.3",
4
4
  "description": "General utilities",
5
5
  "main": "dist/index.js",
6
6
  "typings": "./dist/index.d.ts",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "homepage": "https://github.com/furystack/furystack",
36
36
  "devDependencies": {
37
- "@types/jest": "^27.0.2"
37
+ "@types/jest": "^27.4.0"
38
38
  },
39
- "gitHead": "963fefda256700fba2f230538653573e4fb7b64d"
39
+ "gitHead": "dcee00dfb4035fe382ec726af4d614ef9d8a579f"
40
40
  }
package/src/index.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  export * from './disposable'
2
2
  export * from './deep-merge'
3
- export * from './filter-async'
4
3
  export * from './debounce'
5
4
  export * from './observable-value'
6
- export * from './retrier'
7
5
  export * from './value-observer'
8
6
  export * from './path-helper'
9
7
  export * from './sleep-async'
@@ -4,32 +4,6 @@ import { PathHelper } from './path-helper'
4
4
  * Path Helper tests
5
5
  */
6
6
  export const pathHelperTests = describe('PathHelper', () => {
7
- describe('#isItemSegment()', () => {
8
- it('Should return true for item segments with string key "(\'Item1\')"', () => {
9
- expect(PathHelper.isItemSegment("('Item1')")).toBe(true)
10
- })
11
-
12
- it('Should return true for item segments with numeric key "(42)"', () => {
13
- expect(PathHelper.isItemSegment('(42)')).toBe(true)
14
- })
15
-
16
- it('Should return false for string keys w/o quotes', () => {
17
- expect(PathHelper.isItemSegment('(invalidValue)')).toBe(false)
18
- })
19
-
20
- it('Should return false for invalid string keys', () => {
21
- expect(PathHelper.isItemSegment('(123invalidValue)')).toBe(false)
22
- })
23
-
24
- it('Should return false for non-item segments', () => {
25
- expect(PathHelper.isItemSegment('Item1')).toBe(false)
26
- })
27
-
28
- it('Should return false for inconsistent quotation', () => {
29
- expect(PathHelper.isItemSegment("('123invalidValue)")).toBe(false)
30
- })
31
- })
32
-
33
7
  describe('#trimSlashes()', () => {
34
8
  it('should trim from the beginning of the segment', () => {
35
9
  expect(PathHelper.trimSlashes('/segment')).toBe('segment')
@@ -48,75 +22,6 @@ export const pathHelperTests = describe('PathHelper', () => {
48
22
  })
49
23
  })
50
24
 
51
- describe('#isItemPath()', () => {
52
- it('should return true for item paths', () => {
53
- const isAnItem = PathHelper.isItemPath("/workspace('project')")
54
- expect(isAnItem).toBe(true)
55
- })
56
-
57
- it('should return false for collection paths', () => {
58
- const isNotAnItem = PathHelper.isItemPath('/workspace/project')
59
- expect(isNotAnItem).toBe(false)
60
- })
61
-
62
- it('should return true for reference paths', () => {
63
- const isAnItem = PathHelper.isItemPath("/workspace/('project')/CustomAction")
64
- expect(isAnItem).toBe(true)
65
- })
66
-
67
- it('should return true for reference paths with ids', () => {
68
- const isAnItem = PathHelper.isItemPath('/workspaces/(22)/CustomAction')
69
- expect(isAnItem).toBe(true)
70
- })
71
- })
72
-
73
- describe('#getContentUrlbyId()', () => {
74
- it('should return by path if the provided value is a path', () => {
75
- const url = PathHelper.getContentUrl('/workspace/project')
76
- expect(url).toBe("workspace/('project')")
77
- })
78
-
79
- it('should return by id if the provided value is id', () => {
80
- const contentUrl = PathHelper.getContentUrl(1)
81
- expect(contentUrl).toBe('content(1)')
82
- })
83
- })
84
-
85
- describe('#getContentUrlbyId()', () => {
86
- it('should create the path with the correct format', () => {
87
- const contentUrl = PathHelper.getContentUrlbyId(1)
88
- expect(contentUrl).toBe('content(1)')
89
- })
90
- })
91
-
92
- describe('#getContentUrlByPath()', () => {
93
- it('should return a proper item path by the given path', () => {
94
- const contentUrl = PathHelper.getContentUrlByPath('/workspace/project')
95
- expect(contentUrl).toBe("workspace/('project')")
96
- })
97
-
98
- it('should return the path itself if it is an item path already', () => {
99
- const contentUrl = PathHelper.getContentUrlByPath("/workspace('project')")
100
- expect(contentUrl).toBe("workspace/('project')")
101
- })
102
-
103
- it('should return the path itself for reference paths', () => {
104
- const contentUrl = PathHelper.getContentUrlByPath("/workspace('project')/Owner")
105
- expect(contentUrl).toBe("workspace/('project')/Owner")
106
- })
107
-
108
- it('should return an error message if the given argument is an empty string', () => {
109
- expect(() => {
110
- PathHelper.getContentUrlByPath('')
111
- }).toThrow()
112
- })
113
-
114
- it('should return a proper item path for Root only', () => {
115
- const path = PathHelper.getContentUrlByPath('/Root')
116
- expect(path).toBe("('Root')")
117
- })
118
- })
119
-
120
25
  describe('#joinPaths()', () => {
121
26
  it('should join with slashes', () => {
122
27
  const joined = PathHelper.joinPaths('path1', 'path2', 'path3')
@@ -150,19 +55,15 @@ export const pathHelperTests = describe('PathHelper', () => {
150
55
 
151
56
  describe('#getSegments()', () => {
152
57
  it('Should split the path to segments', () => {
153
- expect(PathHelper.getSegments("Root/Example('Content1')")).toEqual(['Root', 'Example', "('Content1')"])
58
+ expect(PathHelper.getSegments("Root/Example/('Content1')")).toEqual(['Root', 'Example', "('Content1')"])
154
59
  })
155
60
  })
156
61
 
157
62
  describe('#getParentPath()', () => {
158
- it('Should return the parent path in case of more than 1 segments', () => {
63
+ it('Should return the parent path', () => {
159
64
  expect(PathHelper.getParentPath('Root/Example/Content')).toBe('Root/Example')
160
65
  })
161
66
 
162
- it('Should return the parent path in case of more than 1 segments with item path', () => {
163
- expect(PathHelper.getParentPath("Root/Example('Content')")).toBe('Root/Example')
164
- })
165
-
166
67
  it('Should return the path in case of 1 segments', () => {
167
68
  expect(PathHelper.getParentPath('Root')).toBe('Root')
168
69
  })
@@ -22,88 +22,13 @@ export class PathHelper {
22
22
 
23
23
  /**
24
24
  * Splits a full path into path segments,
25
- * e.g.: /Root/Example('Content1') will be ["Root", "Example", "('Content1')"]
25
+ * e.g.: /Root/Example/stuff
26
26
  *
27
27
  * @param path The path to be splitted
28
28
  * @returns {string[]} the segments for the path
29
29
  */
30
30
  public static getSegments(path: string): string[] {
31
- return path
32
- .split(/\/|[(][']|[(]/g)
33
- .filter((segment) => segment && segment.length)
34
- .map((segment) => {
35
- if (segment.endsWith("')")) {
36
- segment = `('${segment}`
37
- } else if (segment.endsWith(')')) {
38
- segment = `(${segment}`
39
- }
40
- return segment
41
- })
42
- }
43
-
44
- /**
45
- * Checks if a specific segment is an Item segment or not (like "('Content1')"" or "(654)")
46
- *
47
- * @param segment The segment to be examined
48
- * @returns a boolean value that indicates if the segment is an item segment
49
- */
50
- public static isItemSegment(segment: string): boolean {
51
- return RegExp(/^\('+[\s\S]+'\)$/).test(segment) || RegExp(/^\(+\d+\)$/).test(segment)
52
- }
53
-
54
- /**
55
- * Method that tells if a path is an item path or an item reference path (e.g. contains an Item segment).
56
- *
57
- * @param {string} path Path that you want to test.
58
- * @returns {boolean} Returns if the given path is a path of a Content or not.
59
- */
60
- public static isItemPath(path: string): boolean {
61
- const segments = this.getSegments(path)
62
- const itemSegment = segments.find((s) => this.isItemSegment(s))
63
- return itemSegment && itemSegment.length ? true : false
64
- }
65
-
66
- /**
67
- * Returns the full path for a content based on its Id or Path
68
- *
69
- * @param {string | number} idOrPath the Id Or Path of the content
70
- * @returns A full Id or Path-based url of the content (e.g. *'/content(1)'* or *'/Root/Example/('Content')'*)
71
- */
72
- public static getContentUrl(idOrPath: string | number): string {
73
- const parsed = parseInt(idOrPath as string, 10)
74
- if (isNaN(parsed)) {
75
- return this.getContentUrlByPath(idOrPath.toString())
76
- } else {
77
- return this.getContentUrlbyId(parsed)
78
- }
79
- }
80
-
81
- /**
82
- * Method that gets the URL that refers to a single item in the Sense/Net Content Repository
83
- *
84
- * @param {string} path Path that you want to format.
85
- * @returns {string} Path in entity format e.g. /workspaces('project') from /workspaces/project
86
- */
87
- public static getContentUrlByPath(path: string): string {
88
- if (!path) {
89
- throw Error('Path is empty')
90
- }
91
-
92
- const segments = this.getSegments(path)
93
- if (!this.isItemPath(path)) {
94
- segments[segments.length - 1] = `('${segments[segments.length - 1]}')`
95
- }
96
- return segments.join('/')
97
- }
98
-
99
- /**
100
- * Method that gets the URL that refers to a single item in the Sense/Net Content Repository by its Id
101
- *
102
- * @param id {number} Id of the Content.
103
- * @returns {string} e.g. /content(123)
104
- */
105
- public static getContentUrlbyId(id: number): string {
106
- return `content(${id})`
31
+ return path.split('/').filter((segment) => segment && segment.length)
107
32
  }
108
33
 
109
34
  /**
@@ -37,5 +37,5 @@ export class ValueObserver<T> implements Disposable {
37
37
  * @param observable The related Observable object
38
38
  * @param callback The callback that will be fired on change
39
39
  */
40
- constructor(private readonly observable: ObservableValue<T>, public callback: ValueChangeCallback<T>) {}
40
+ constructor(public readonly observable: ObservableValue<T>, public callback: ValueChangeCallback<T>) {}
41
41
  }
@@ -1,20 +0,0 @@
1
- /**
2
- * The async variant of the Array.filter() method that
3
- *
4
- * @param values An iterable of elements to filter
5
- * @param callbackFn The async callback that will be executed on the elements
6
- * @returns Promise<T[]>
7
- */
8
- export declare const filterAsync: <T>(values: Iterable<T>, callbackFn: (entry: T) => Promise<boolean>) => Promise<T[]>;
9
- declare global {
10
- /**
11
- * Defines an array of elements
12
- */
13
- export interface Array<T> {
14
- /**
15
- * Returns a promise with a new array of elements that meets the specified async callback
16
- */
17
- filterAsync: (callbackFn: (entry: T) => Promise<boolean>) => Promise<T[]>;
18
- }
19
- }
20
- //# sourceMappingURL=filter-async.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"filter-async.d.ts","sourceRoot":"","sources":["../src/filter-async.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,qDAA4D,QAAQ,OAAO,CAAC,iBAMnG,CAAA;AAED,OAAO,CAAC,MAAM,CAAC;IACb;;OAEG;IACH,MAAM,WAAW,KAAK,CAAC,CAAC;QACtB;;WAEG;QACH,WAAW,EAAE,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,CAAA;KAC1E;CACF"}