@nymphjs/sorter 1.0.0-beta.12 → 1.0.0-beta.121

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/src/Sorter.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type SortOptions = {
1
+ export type SortOptions<Entity extends Object> = {
2
2
  /** Sort case sensitively. */
3
3
  caseSensitive?: boolean;
4
4
  /** Reverse the sort order. */
@@ -7,6 +7,8 @@ export type SortOptions = {
7
7
  collatorOptions?: Intl.CollatorOptions;
8
8
  /** A custom comparator to use. This overrides all other options except reverse. */
9
9
  comparator?: (a: any, b: any) => number;
10
+ /** A function to resolve order of entities with identical properties. */
11
+ identiticalResolver?: (a: Entity, b: Entity) => number;
10
12
  };
11
13
 
12
14
  /**
@@ -20,6 +22,7 @@ export default class Sorter<Entity extends Object> {
20
22
  private sortParent: string | null = null;
21
23
  private collator: Intl.Collator = new Intl.Collator();
22
24
  private comparator: ((a: any, b: any) => number) | undefined = undefined;
25
+ private identiticalResolver: (a: Entity, b: Entity) => number = (a, b) => 0;
23
26
 
24
27
  constructor(array: Entity[]) {
25
28
  this.array = array as (Entity & { [k: string]: any })[];
@@ -27,7 +30,7 @@ export default class Sorter<Entity extends Object> {
27
30
 
28
31
  private _arraySortProperty(
29
32
  a: Entity & { [k: string]: any },
30
- b: Entity & { [k: string]: any }
33
+ b: Entity & { [k: string]: any },
31
34
  ) {
32
35
  const prop = this.sortProperty as string;
33
36
  const parent = this.sortParent as string;
@@ -68,15 +71,26 @@ export default class Sorter<Entity extends Object> {
68
71
  const aProp = a[prop];
69
72
  const bProp = b[prop];
70
73
  if (this.comparator != null) {
71
- return this.comparator(aProp, bProp);
74
+ const result = this.comparator(aProp, bProp);
75
+ if (result === 0) {
76
+ return this.identiticalResolver(a, b);
77
+ } else {
78
+ return result;
79
+ }
72
80
  } else if (typeof aProp === 'string' && typeof bProp === 'string') {
73
- return this.collator.compare(aProp, bProp);
81
+ const result = this.collator.compare(aProp, bProp);
82
+ if (result === 0) {
83
+ return this.identiticalResolver(a, b);
84
+ } else {
85
+ return result;
86
+ }
74
87
  } else if (aProp > bProp) {
75
88
  return 1;
76
89
  } else if (aProp < bProp) {
77
90
  return -1;
91
+ } else {
92
+ return this.identiticalResolver(a, b);
78
93
  }
79
- return 0;
80
94
  }
81
95
 
82
96
  /**
@@ -92,83 +106,103 @@ export default class Sorter<Entity extends Object> {
92
106
  public hsort(
93
107
  property: string,
94
108
  parentProperty: string,
95
- sortOptions?: SortOptions
109
+ {
110
+ caseSensitive = false,
111
+ reverse = false,
112
+ collatorOptions = undefined,
113
+ comparator = undefined,
114
+ identiticalResolver = (a, b) => 0,
115
+ }: SortOptions<Entity> = {},
96
116
  ): Entity[] {
97
- // First sort by the requested property.
98
- this.sort(property, sortOptions);
99
117
  if (typeof parentProperty === 'undefined' || parentProperty === null) {
118
+ // Just sort by the requested property.
119
+ this.sort(property, {
120
+ caseSensitive,
121
+ reverse,
122
+ collatorOptions,
123
+ comparator,
124
+ });
100
125
  return this.array;
101
126
  }
102
127
 
103
- // Now sort by children.
104
- let newArray: (Entity & { [k: string]: any })[] = [];
105
- // Look for entities ready to go in order.
106
- let changed: boolean;
107
- while (this.array.length) {
108
- changed = false;
109
- for (let key = 0; key < this.array.length; key++) {
110
- // Must break after adding one, so any following children don't go in
111
- // the wrong order.
112
- if (
113
- !(parentProperty in this.array[key]) ||
114
- this.array[key][parentProperty] == null ||
115
- typeof this.array[key][parentProperty].$inArray !== 'function' ||
116
- !this.array[key][parentProperty].$inArray([
117
- ...newArray,
118
- ...this.array,
119
- ])
120
- ) {
121
- // If they have no parent (or their parent isn't in the array), they
122
- // go on the end.
123
- newArray.push(this.array[key]);
124
- this.array.splice(key, 1);
125
- changed = true;
126
- break;
127
- } else if (
128
- typeof this.array[key][parentProperty].$arraySearch === 'function'
129
- ) {
130
- // Else find the parent.
131
- const pkey = this.array[key][parentProperty].$arraySearch(newArray);
132
- if (pkey !== -1) {
133
- // And insert after the parent.
134
- // This makes entities go to the end of the child list.
135
- const ancestry = [this.array[key][parentProperty].guid];
136
- let newKey = pkey;
137
- while (
138
- newKey + 1 < newArray.length &&
139
- parentProperty in newArray[newKey + 1] &&
140
- newArray[newKey + 1][parentProperty] != null &&
141
- ancestry.indexOf(newArray[newKey + 1][parentProperty].guid) !== -1
142
- ) {
143
- ancestry.push(newArray[newKey + 1].guid);
144
- newKey += 1;
145
- }
146
- // Where to place the entity.
147
- newKey += 1;
148
- if (newKey < newArray.length) {
149
- // If it already exists, we have to splice it in.
150
- newArray.splice(newKey, 0, this.array[key]);
151
- } else {
152
- // Else just add it.
153
- newArray.push(this.array[key]);
154
- }
155
- this.array.splice(key, 1);
156
- changed = true;
157
- break;
158
- }
128
+ this.sortProperty = property;
129
+ this.sortParent = null;
130
+ this.collator = new Intl.Collator(
131
+ undefined,
132
+ collatorOptions || {
133
+ sensitivity: caseSensitive ? 'case' : 'base',
134
+ },
135
+ );
136
+ this.comparator = comparator;
137
+ this.identiticalResolver = identiticalResolver;
138
+ const sort = (array: Entity[]) => {
139
+ // Sort by the requested property.
140
+ array.sort(this._arraySortProperty.bind(this));
141
+ if (reverse) {
142
+ array.reverse();
143
+ }
144
+ return array;
145
+ };
146
+
147
+ // Pick out all of the children.
148
+ const guidEntries: { [k: string]: Entity[] } = {};
149
+ const newEntries = new Map<Entity, Entity[]>();
150
+
151
+ // There is no incrementor in this for loop on purpose. It is incremented
152
+ // conditionally.
153
+ for (let i = 0; i < this.array.length;) {
154
+ const entity = this.array[i];
155
+ const parent = entity[parentProperty];
156
+ if (parent == null) {
157
+ i++;
158
+ } else if (parent.guid != null) {
159
+ this.array.splice(i, 1);
160
+ if (!(parent.guid in guidEntries)) {
161
+ guidEntries[parent.guid] = [];
162
+ }
163
+ guidEntries[parent.guid].push(entity);
164
+ } else {
165
+ this.array.splice(i, 1);
166
+ let entries: Entity[] = [];
167
+ if (newEntries.has(parent)) {
168
+ entries = newEntries.get(parent) || [];
159
169
  }
170
+ entries.push(entity);
171
+ newEntries.set(parent, entries);
160
172
  }
161
- if (!changed) {
162
- // If there are any unexpected errors and the array isn't changed, just
163
- // stick the rest on the end.
164
- if (this.array.length) {
165
- newArray = newArray.concat(this.array);
166
- this.array.splice(0, this.array.length);
173
+ }
174
+
175
+ // Sort the top level entries.
176
+ sort(this.array);
177
+
178
+ // Now place all of the children back in order.
179
+ for (let i = 0; i < this.array.length; i++) {
180
+ const entity = this.array[i];
181
+ if (entity.guid != null) {
182
+ if (entity.guid in guidEntries) {
183
+ this.array.splice(i + 1, 0, ...sort(guidEntries[entity.guid]));
184
+ delete guidEntries[entity.guid];
185
+ }
186
+ } else {
187
+ if (newEntries.has(entity)) {
188
+ this.array.splice(
189
+ i + 1,
190
+ 0,
191
+ ...sort(newEntries.get(entity.guid) || []),
192
+ );
193
+ newEntries.delete(entity);
167
194
  }
168
195
  }
169
196
  }
170
- // Now push the new array out.
171
- this.array.splice(0, 0, ...newArray);
197
+
198
+ // Now place any orphans on the end.
199
+ for (let orphans of Object.values(guidEntries)) {
200
+ this.array.splice(this.array.length, 0, ...sort(orphans));
201
+ }
202
+ for (let [parent, orphans] of newEntries) {
203
+ this.array.splice(this.array.length, 0, ...sort(orphans));
204
+ }
205
+
172
206
  return this.array as Entity[];
173
207
  }
174
208
 
@@ -189,7 +223,8 @@ export default class Sorter<Entity extends Object> {
189
223
  reverse = false,
190
224
  collatorOptions = undefined,
191
225
  comparator = undefined,
192
- }: SortOptions = {}
226
+ identiticalResolver = (a, b) => 0,
227
+ }: SortOptions<Entity> = {},
193
228
  ): Entity[] {
194
229
  // Sort by the requested property.
195
230
  this.sortProperty = property;
@@ -199,9 +234,10 @@ export default class Sorter<Entity extends Object> {
199
234
  collatorOptions || {
200
235
  sensitivity: caseSensitive ? 'case' : 'base',
201
236
  caseFirst: 'false',
202
- }
237
+ },
203
238
  );
204
239
  this.comparator = comparator;
240
+ this.identiticalResolver = identiticalResolver;
205
241
  this.array.sort(this._arraySortProperty.bind(this));
206
242
  if (reverse) {
207
243
  this.array.reverse();
@@ -213,6 +249,7 @@ export default class Sorter<Entity extends Object> {
213
249
  * Sort an array of entities by a specified property's value.
214
250
  *
215
251
  * @param property The name of the property to sort entities by.
252
+ * @param identiticalResolver A function to resolve order of identical entities.
216
253
  */
217
254
  public sort(
218
255
  property: string,
@@ -221,7 +258,8 @@ export default class Sorter<Entity extends Object> {
221
258
  reverse = false,
222
259
  collatorOptions = undefined,
223
260
  comparator = undefined,
224
- }: SortOptions = {}
261
+ identiticalResolver = (a, b) => 0,
262
+ }: SortOptions<Entity> = {},
225
263
  ): Entity[] {
226
264
  // Sort by the requested property.
227
265
  this.sortProperty = property;
@@ -230,9 +268,10 @@ export default class Sorter<Entity extends Object> {
230
268
  undefined,
231
269
  collatorOptions || {
232
270
  sensitivity: caseSensitive ? 'case' : 'base',
233
- }
271
+ },
234
272
  );
235
273
  this.comparator = comparator;
274
+ this.identiticalResolver = identiticalResolver;
236
275
  this.array.sort(this._arraySortProperty.bind(this));
237
276
  if (reverse) {
238
277
  this.array.reverse();
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './Sorter';
2
- import Sorter, { SortOptions } from './Sorter';
1
+ export * from './Sorter.js';
2
+ import Sorter, { SortOptions } from './Sorter.js';
3
3
  export { Sorter, SortOptions };
@@ -6,6 +6,7 @@ export class TestModel {
6
6
  public guid: string;
7
7
  public name?: string;
8
8
  public number?: number;
9
+ public fallback?: number;
9
10
  public parent?: TestModel;
10
11
 
11
12
  constructor() {
package/tsconfig.json CHANGED
@@ -2,12 +2,15 @@
2
2
  "extends": "@tsconfig/recommended/tsconfig.json",
3
3
 
4
4
  "compilerOptions": {
5
- "lib": ["DOM", "ES2021"],
6
- "target": "ES2021",
5
+ "types": ["jest"],
6
+ "module": "nodenext",
7
+ "moduleResolution": "nodenext",
8
+ "lib": ["DOM", "es2023"],
9
+ "target": "es2023",
7
10
  "noImplicitAny": true,
8
- "removeComments": true,
11
+ "removeComments": false,
9
12
  "sourceMap": true,
10
- "outDir": "lib",
13
+ "outDir": "dist",
11
14
  "resolveJsonModule": true,
12
15
  "rootDir": "src/",
13
16
  "declaration": true
package/typedoc.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": ["../../typedoc.base.json"],
3
+ "entryPoints": ["src/index.ts"]
4
+ }
package/lib/Sorter.d.ts DELETED
@@ -1,20 +0,0 @@
1
- export type SortOptions = {
2
- caseSensitive?: boolean;
3
- reverse?: boolean;
4
- collatorOptions?: Intl.CollatorOptions;
5
- comparator?: (a: any, b: any) => number;
6
- };
7
- export default class Sorter<Entity extends Object> {
8
- array: (Entity & {
9
- [k: string]: any;
10
- })[];
11
- private sortProperty;
12
- private sortParent;
13
- private collator;
14
- private comparator;
15
- constructor(array: Entity[]);
16
- private _arraySortProperty;
17
- hsort(property: string, parentProperty: string, sortOptions?: SortOptions): Entity[];
18
- psort(property: string, parentProperty: string, { caseSensitive, reverse, collatorOptions, comparator, }?: SortOptions): Entity[];
19
- sort(property: string, { caseSensitive, reverse, collatorOptions, comparator, }?: SortOptions): Entity[];
20
- }
package/lib/Sorter.js DELETED
@@ -1,144 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class Sorter {
4
- constructor(array) {
5
- this.sortProperty = null;
6
- this.sortParent = null;
7
- this.collator = new Intl.Collator();
8
- this.comparator = undefined;
9
- this.array = array;
10
- }
11
- _arraySortProperty(a, b) {
12
- const prop = this.sortProperty;
13
- const parent = this.sortParent;
14
- if (parent != null &&
15
- a[parent] instanceof Object &&
16
- b[parent] instanceof Object) {
17
- const aParentProp = a[parent][prop];
18
- const bParentProp = b[parent][prop];
19
- if (typeof aParentProp !== 'undefined' ||
20
- typeof bParentProp !== 'undefined') {
21
- if (this.comparator != null) {
22
- const result = this.comparator(aParentProp, bParentProp);
23
- if (result !== 0) {
24
- return result;
25
- }
26
- }
27
- else if (typeof aParentProp === 'string' &&
28
- typeof bParentProp === 'string') {
29
- const result = this.collator.compare(aParentProp, bParentProp);
30
- if (result !== 0) {
31
- return result;
32
- }
33
- }
34
- else if (aParentProp > bParentProp) {
35
- return 1;
36
- }
37
- else if (aParentProp < bParentProp) {
38
- return -1;
39
- }
40
- }
41
- }
42
- const aProp = a[prop];
43
- const bProp = b[prop];
44
- if (this.comparator != null) {
45
- return this.comparator(aProp, bProp);
46
- }
47
- else if (typeof aProp === 'string' && typeof bProp === 'string') {
48
- return this.collator.compare(aProp, bProp);
49
- }
50
- else if (aProp > bProp) {
51
- return 1;
52
- }
53
- else if (aProp < bProp) {
54
- return -1;
55
- }
56
- return 0;
57
- }
58
- hsort(property, parentProperty, sortOptions) {
59
- this.sort(property, sortOptions);
60
- if (typeof parentProperty === 'undefined' || parentProperty === null) {
61
- return this.array;
62
- }
63
- let newArray = [];
64
- let changed;
65
- while (this.array.length) {
66
- changed = false;
67
- for (let key = 0; key < this.array.length; key++) {
68
- if (!(parentProperty in this.array[key]) ||
69
- this.array[key][parentProperty] == null ||
70
- typeof this.array[key][parentProperty].$inArray !== 'function' ||
71
- !this.array[key][parentProperty].$inArray([
72
- ...newArray,
73
- ...this.array,
74
- ])) {
75
- newArray.push(this.array[key]);
76
- this.array.splice(key, 1);
77
- changed = true;
78
- break;
79
- }
80
- else if (typeof this.array[key][parentProperty].$arraySearch === 'function') {
81
- const pkey = this.array[key][parentProperty].$arraySearch(newArray);
82
- if (pkey !== -1) {
83
- const ancestry = [this.array[key][parentProperty].guid];
84
- let newKey = pkey;
85
- while (newKey + 1 < newArray.length &&
86
- parentProperty in newArray[newKey + 1] &&
87
- newArray[newKey + 1][parentProperty] != null &&
88
- ancestry.indexOf(newArray[newKey + 1][parentProperty].guid) !== -1) {
89
- ancestry.push(newArray[newKey + 1].guid);
90
- newKey += 1;
91
- }
92
- newKey += 1;
93
- if (newKey < newArray.length) {
94
- newArray.splice(newKey, 0, this.array[key]);
95
- }
96
- else {
97
- newArray.push(this.array[key]);
98
- }
99
- this.array.splice(key, 1);
100
- changed = true;
101
- break;
102
- }
103
- }
104
- }
105
- if (!changed) {
106
- if (this.array.length) {
107
- newArray = newArray.concat(this.array);
108
- this.array.splice(0, this.array.length);
109
- }
110
- }
111
- }
112
- this.array.splice(0, 0, ...newArray);
113
- return this.array;
114
- }
115
- psort(property, parentProperty, { caseSensitive = false, reverse = false, collatorOptions = undefined, comparator = undefined, } = {}) {
116
- this.sortProperty = property;
117
- this.sortParent = parentProperty;
118
- this.collator = new Intl.Collator(undefined, collatorOptions || {
119
- sensitivity: caseSensitive ? 'case' : 'base',
120
- caseFirst: 'false',
121
- });
122
- this.comparator = comparator;
123
- this.array.sort(this._arraySortProperty.bind(this));
124
- if (reverse) {
125
- this.array.reverse();
126
- }
127
- return this.array;
128
- }
129
- sort(property, { caseSensitive = false, reverse = false, collatorOptions = undefined, comparator = undefined, } = {}) {
130
- this.sortProperty = property;
131
- this.sortParent = null;
132
- this.collator = new Intl.Collator(undefined, collatorOptions || {
133
- sensitivity: caseSensitive ? 'case' : 'base',
134
- });
135
- this.comparator = comparator;
136
- this.array.sort(this._arraySortProperty.bind(this));
137
- if (reverse) {
138
- this.array.reverse();
139
- }
140
- return this.array;
141
- }
142
- }
143
- exports.default = Sorter;
144
- //# sourceMappingURL=Sorter.js.map
package/lib/Sorter.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"Sorter.js","sourceRoot":"","sources":["../src/Sorter.ts"],"names":[],"mappings":";;AAgBA,MAAqB,MAAM;IAOzB,YAAY,KAAe;QALnB,iBAAY,GAAkB,IAAI,CAAC;QACnC,eAAU,GAAkB,IAAI,CAAC;QACjC,aAAQ,GAAkB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9C,eAAU,GAA6C,SAAS,CAAC;QAGvE,IAAI,CAAC,KAAK,GAAG,KAA0C,CAAC;IAC1D,CAAC;IAEO,kBAAkB,CACxB,CAAgC,EAChC,CAAgC;QAEhC,MAAM,IAAI,GAAG,IAAI,CAAC,YAAsB,CAAC;Q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