Skip to content

Commit 06eff57

Browse files
author
Steve Thompson
committed
More changes to README
1 parent 5f26f15 commit 06eff57

File tree

10 files changed

+157
-760
lines changed

10 files changed

+157
-760
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ arr.data = [1,2,3,4,5,6,7];
5454
5555
```
5656

57+
## Performance
58+
59+
PublicArray has a large number of dependencies. You should keep this in mind when optimizing the
60+
performance of your app. If your code only uses one property of PublicArray, like for
61+
instance .replace, you will get a slight performance boost if you just use an instance of
62+
PublicArrayReplacer instead:
63+
```
64+
let replace = new PublicArrayReplacer(arr);
65+
```
5766

5867
## License
5968
[MIT](https://choosealicense.com/licenses/mit/)

dist/privy/PublicArray.d.ts

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import { PublicArrayFilter } from '@writetome51/public-array-filter';
1010

1111

1212
/**************
13-
This class is called PublicArray because an array is contained inside it, in a public property.
13+
This class is called PublicArray because an array is contained inside it,
14+
in a public property: 'data'
1415
1516
The main reason you would use this class is if you hate JavaScript's built-in Array
1617
methods, like .slice(), .splice(), .push(), and .shift(). This class has much clearer
@@ -21,9 +22,9 @@ import { PublicArrayFilter } from '@writetome51/public-array-filter';
2122
let arr = getPublicArray( [1,2,3,4,5,6] );
2223
arr.remove.tail(2); // arr.data is now [1,2,3,4]
2324
if (arr.notEmpty) arr.prepend([10]); // arr.data is now [10,1,2,3,4]
24-
25-
To access the array itself, you access the 'data' property.
2625
*************/
26+
27+
2728
export declare class PublicArray extends PublicArrayContent {
2829

2930
private _filter;
@@ -36,7 +37,23 @@ export declare class PublicArray extends PublicArrayContent {
3637
private _sort;
3738

3839

40+
/***************
41+
Public Properties:
42+
43+
readonly copy: PublicArray; // independent copy of this instance.
44+
readonly filter: PublicArrayFilter;
45+
readonly getConverted: PublicArrayGetterConverter;
46+
readonly get: PublicArrayGetter;
47+
readonly getAndRemove: PublicArrayGetterRemover;
48+
readonly insert: PublicArrayInserter;
49+
readonly remove: PublicArrayRemover;
50+
readonly replace: PublicArrayReplacer;
51+
readonly sort: PublicArraySorter;
52+
***************/
53+
54+
3955
constructor(
56+
// begin injected dependencies...
4057
_filter: PublicArrayFilter,
4158
_getConverted: PublicArrayGetterConverter,
4259
_get: PublicArrayGetter,
@@ -45,29 +62,21 @@ export declare class PublicArray extends PublicArrayContent {
4562
_remove: PublicArrayRemover,
4663
_replace: PublicArrayReplacer,
4764
_sort: PublicArraySorter,
65+
// ... end injected dependencies
4866

49-
// The actual array:
67+
// the actual array:
5068
data?: any[]
5169
);
5270

5371

54-
readonly filter: PublicArrayFilter;
55-
readonly getConverted: PublicArrayGetterConverter;
56-
readonly get: PublicArrayGetter;
57-
readonly getAndRemove: PublicArrayGetterRemover;
58-
readonly insert: PublicArrayInserter;
59-
readonly remove: PublicArrayRemover;
60-
readonly replace: PublicArrayReplacer;
61-
readonly sort: PublicArraySorter;
6272
readonly copy: PublicArray;
6373

6474

65-
6675
append(values: any[]): this;
6776

6877

6978
prepend(values: any[]): this;
7079

7180

72-
forEach(iterationFunction: Function): this;
81+
forEach(iterationFunction: any): this;
7382
}

dist/privy/PublicArray.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ var array_append_prepend_1 = require("@writetome51/array-append-prepend");
1717
var di_factory_1 = require("@writetome51/di-factory");
1818
var public_array_content_1 = require("@writetome51/public-array-content");
1919
/**************
20-
This class is called PublicArray because an array is contained inside it, in a public property.
20+
This class is called PublicArray because an array is contained inside it,
21+
in a public property: 'data'
2122
2223
The main reason you would use this class is if you hate JavaScript's built-in Array
2324
methods, like .slice(), .splice(), .push(), and .shift(). This class has much clearer
@@ -28,16 +29,28 @@ var public_array_content_1 = require("@writetome51/public-array-content");
2829
let arr = getPublicArray( [1,2,3,4,5,6] );
2930
arr.remove.tail(2); // arr.data is now [1,2,3,4]
3031
if (arr.notEmpty) arr.prepend([10]); // arr.data is now [10,1,2,3,4]
31-
32-
To access the array itself, you access the 'data' property.
3332
*************/
3433
var PublicArray = /** @class */ (function (_super) {
3534
__extends(PublicArray, _super);
35+
/***************
36+
Public Properties:
37+
38+
readonly copy: PublicArray; // independent copy of this instance.
39+
readonly filter: PublicArrayFilter;
40+
readonly getConverted: PublicArrayGetterConverter;
41+
readonly get: PublicArrayGetter;
42+
readonly getAndRemove: PublicArrayGetterRemover;
43+
readonly insert: PublicArrayInserter;
44+
readonly remove: PublicArrayRemover;
45+
readonly replace: PublicArrayReplacer;
46+
readonly sort: PublicArraySorter;
47+
***************/
3648
function PublicArray(
3749
// begin injected dependencies...
3850
_filter, _getConverted, _get, _getAndRemove, _insert, _remove, _replace, _sort,
3951
// ... end injected dependencies
40-
data) {
52+
data // the actual array, represented by inherited property this.data
53+
) {
4154
if (data === void 0) { data = []; }
4255
var _this = _super.call(this, data) || this;
4356
_this._filter = _filter;
@@ -65,7 +78,7 @@ var PublicArray = /** @class */ (function (_super) {
6578
// this.copy -- returns independent copy of this.
6679
get: function () {
6780
// @ts-ignore
68-
return di_factory_1.DIFactory.getInstance(PublicArray, [this.get.copy]);
81+
return di_factory_1.DIFactory.getInstance(PublicArray, [this.get.copy()]);
6982
},
7083
enumerable: true,
7184
configurable: true

lib/tests.js renamed to dist/tests.d.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
"use strict";
2-
Object.defineProperty(exports, "__esModule", { value: true });
3-
var index_1 = require("./index");
4-
var arr = index_1.getPublicArray([1, 2, 3, 4, 5, 6, 7, 8, 9]);
5-
var otherArr = arr.data;
6-
otherArr.length = 0;
7-
console.log(otherArr);
8-
console.log(arr.data);
1+
export {};
92
/************
103
arr.remove.allAfterFirst(6);
114
arr.remove.allBeforeFirst(3);

dist/tests.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
33
var index_1 = require("./index");
4+
console.log('hello');
5+
//let arr = new PublicArrayReplacer([1, 2, 3, 4, 5, 6, 7, 8, 9]);
46
var arr = index_1.getPublicArray([1, 2, 3, 4, 5, 6, 7, 8, 9]);
5-
var otherArr = arr.data;
7+
console.log(arr.remove.byIndex(0).byIndexes([1, 3, 5]).adjacentAt(1, 2));
8+
var arrCopy = arr.copy;
9+
console.log(arrCopy);
10+
/****************
11+
12+
13+
let otherArr = arr.data;
14+
615
otherArr.length = 0;
16+
717
console.log(otherArr);
18+
819
console.log(arr.data);
20+
*************/
921
/************
1022
arr.remove.allAfterFirst(6);
1123
arr.remove.allBeforeFirst(3);

lib/privy/PublicArray.js

Lines changed: 0 additions & 89 deletions
This file was deleted.

lib/privy/PublicArray.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import { PublicArrayFilter } from '@writetome51/public-array-filter';
1212

1313

1414
/**************
15-
This class is called PublicArray because an array is contained inside it, in a public property.
15+
This class is called PublicArray because an array is contained inside it,
16+
in a public property: 'data'
1617
1718
The main reason you would use this class is if you hate JavaScript's built-in Array
1819
methods, like .slice(), .splice(), .push(), and .shift(). This class has much clearer
@@ -23,13 +24,25 @@ import { PublicArrayFilter } from '@writetome51/public-array-filter';
2324
let arr = getPublicArray( [1,2,3,4,5,6] );
2425
arr.remove.tail(2); // arr.data is now [1,2,3,4]
2526
if (arr.notEmpty) arr.prepend([10]); // arr.data is now [10,1,2,3,4]
26-
27-
To access the array itself, you access the 'data' property.
2827
*************/
2928

3029

3130
export class PublicArray extends PublicArrayContent {
3231

32+
/***************
33+
Public Properties:
34+
35+
readonly copy: PublicArray; // independent copy of this instance.
36+
readonly filter: PublicArrayFilter;
37+
readonly getConverted: PublicArrayGetterConverter;
38+
readonly get: PublicArrayGetter;
39+
readonly getAndRemove: PublicArrayGetterRemover;
40+
readonly insert: PublicArrayInserter;
41+
readonly remove: PublicArrayRemover;
42+
readonly replace: PublicArrayReplacer;
43+
readonly sort: PublicArraySorter;
44+
***************/
45+
3346

3447
constructor(
3548
// begin injected dependencies...
@@ -43,7 +56,7 @@ export class PublicArray extends PublicArrayContent {
4356
private _sort: PublicArraySorter,
4457
// ... end injected dependencies
4558

46-
data = []
59+
data = [] // the actual array, represented by inherited property this.data
4760
) {
4861

4962
super(data);
@@ -67,7 +80,7 @@ export class PublicArray extends PublicArrayContent {
6780
// this.copy -- returns independent copy of this.
6881
get copy(): PublicArray {
6982
// @ts-ignore
70-
return DIFactory.getInstance(PublicArray, [this.get.copy]);
83+
return DIFactory.getInstance(PublicArray, [this.get.copy()]);
7184
}
7285

7386

lib/tests.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
import { getPublicArray } from './index';
2+
import { PublicArrayReplacer } from '@writetome51/public-array-replacer';
23

3-
4+
console.log('hello');
5+
//let arr = new PublicArrayReplacer([1, 2, 3, 4, 5, 6, 7, 8, 9]);
46
let arr = getPublicArray([1, 2, 3, 4, 5, 6, 7, 8, 9]);
7+
console.log(arr.remove.byIndex(0).byIndexes([1,3,5]).adjacentAt(1, 2));
8+
let arrCopy = arr.copy;
9+
console.log(arrCopy);
10+
11+
/****************
12+
513
614
let otherArr = arr.data;
715
@@ -10,6 +18,7 @@ otherArr.length = 0;
1018
console.log(otherArr);
1119
1220
console.log(arr.data);
21+
*************/
1322

1423

1524

0 commit comments

Comments
 (0)