Skip to content

Commit 23445ca

Browse files
author
Steve Thompson
committed
Updated dependency @writetome51/public-array-content to version ~1.2.0.
The .copy property has been moved to PublicArrayContent. Added comments to lib/index.ts. Minor update to README.
1 parent dd53a23 commit 23445ca

File tree

7 files changed

+55
-82
lines changed

7 files changed

+55
-82
lines changed

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ new PublicArray(array = [])
5151
###### This is the array to be operated on.
5252

5353
#### copy: PublicArray (read-only)
54-
###### an independent copy of the PublicArray instance
54+
###### a copy of the PublicArray instance, containing an independent copy of this.data that can be manipulated separately.
5555

5656
#### length: number (read-writable)
5757
###### length of this.data
@@ -545,7 +545,7 @@ forEach(iterationFunction): this
545545
// Behaves same as Array.forEach()
546546
// iterationFunction = function(currentValue, currentIndex?, entireArray?){...}
547547
548-
set(newArray): this
548+
set(newArray): void
549549
// Changes value of this.data to newArray without breaking its memory reference.
550550
// So if there are copies of this.data, the copies will be updated as well.
551551
@@ -609,9 +609,6 @@ performance boost if you just instantiate PublicArrayReplacer instead of PublicA
609609
let replace = new PublicArrayReplacer(array);
610610
replace.adjacentAt(2, ['just', 'an', 'example']);
611611
```
612-
## Inheritance Chain
613-
614-
PublicArray<-PublicArrayContent<-PublicArrayContainer<-BatchGetterSetter<-MethodChainable<-SelfIdentifiable
615612

616613

617614
## License

dist/index.d.ts

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,45 @@ import { PublicArrayContent } from '@writetome51/public-array-content';
88
The main reason you would use this class is if you hate JavaScript's built-in Array
99
methods, like .slice(), .splice(), .push(), and .shift(). This class has much clearer
1010
and expressive method names, and a lot more of them.
11-
12-
A few examples of usage:
13-
14-
let arr = getPublicArray([1,2,3,4,5,6]);
15-
arr.remove.tail(2); // arr.data is now [1,2,3,4]
16-
if (arr.notEmpty) arr.prepend([10]); // arr.data is now [10,1,2,3,4]
1711
**********************/
1812

1913
export declare class PublicArray extends PublicArrayContent {
2014

15+
readonly filter: any;
16+
readonly getConverted: any;
17+
readonly get: any;
18+
readonly getAndRemove: any;
19+
readonly insert: any;
20+
readonly remove: any;
21+
readonly replace: any;
22+
readonly sort: any;
2123

22-
readonly copy: PublicArray; // (an independent copy of this instance).
23-
readonly filter; // PublicArrayFilter
24-
readonly getConverted; // PublicArrayGetterConverter;
25-
readonly get; // PublicArrayGetter;
26-
readonly getAndRemove; // PublicArrayGetterRemover;
27-
readonly insert; // PublicArrayInserter;
28-
readonly remove; // PublicArrayRemover;
29-
readonly replace; // PublicArrayReplacer;
30-
readonly sort; // PublicArraySorter;
31-
24+
private _filter;
25+
private _getConverted;
26+
private _get;
27+
private _getAndRemove;
28+
private _insert;
29+
private _remove;
30+
private _replace;
31+
private _sort;
3232

33-
private _filter; // PublicArrayFilter
34-
private _getConverted; // PublicArrayGetterConverter
35-
private _get; // PublicArrayGetter;
36-
private _getAndRemove; // PublicArrayGetterRemover;
37-
private _insert; // PublicArrayInserter;
38-
private _remove; // PublicArrayRemover;
39-
private _replace; // PublicArrayReplacer;
40-
private _sort; // PublicArraySorter;
33+
private __dependencyClasses;
4134

4235

4336
constructor(data?: any[]);
4437

4538

39+
set(newArray: any[]): void;
40+
41+
4642
append(values: any[]): this;
4743

4844

4945
prepend(values: any[]): this;
5046

5147

52-
forEach(
53-
iterationFunction: (currentValue: any, currentIndex?: number, entireArray?: any[]) => any
54-
): this;
48+
forEach(iterationFunction: (currentValue: any, currentIndex?: number, entireArray?: any[]) => any): this;
5549

5650

57-
set(newArray: any[]): this;
51+
private __getInstancePropertyGetter;
5852
}

dist/index.js

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,15 @@ var public_array_content_1 = require("@writetome51/public-array-content");
2424
The main reason you would use this class is if you hate JavaScript's built-in Array
2525
methods, like .slice(), .splice(), .push(), and .shift(). This class has much clearer
2626
and expressive method names, and a lot more of them.
27-
28-
A few examples of usage:
29-
30-
let arr = getPublicArray([1,2,3,4,5,6]);
31-
arr.remove.tail(2); // arr.data is now [1,2,3,4]
32-
if (arr.notEmpty) arr.prepend([10]); // arr.data is now [10,1,2,3,4]
3327
**********************/
3428
var PublicArray = /** @class */ (function (_super) {
3529
__extends(PublicArray, _super);
3630
function PublicArray(data // the actual array, represented by inherited property this.data
3731
) {
3832
if (data === void 0) { data = []; }
3933
var _this = _super.call(this, data) || this;
34+
// These are not loaded at the top with import statements because we're loading them
35+
// lazily in the getter functions to boost performance.
4036
var dependencyClasses = [
4137
{ path: '@writetome51/public-array-filter', name: 'PublicArrayFilter' },
4238
{ path: '@writetome51/public-array-getter-converter', name: 'PublicArrayGetterConverter' },
@@ -49,11 +45,10 @@ var PublicArray = /** @class */ (function (_super) {
4945
];
5046
_this._createGetterAndOrSetterForEach(
5147
// each of these is a public property:
52-
['filter', 'getConverted', 'get', 'getAndRemove', 'insert',
53-
'remove', 'replace', 'sort'], {
48+
['filter', 'getConverted', 'get', 'getAndRemove', 'insert', 'remove', 'replace', 'sort'], {
5449
get_getterFunction: function (property, index) {
5550
return function () {
56-
// Lazy-Loading is used to instantiate these properties:
51+
// Lazy-Loading is used to instantiate each property:
5752
if (!(_this["_" + property])) { // if property not set...
5853
var dependencyClass = dependencyClasses[index];
5954
// @ts-ignore
@@ -67,15 +62,10 @@ var PublicArray = /** @class */ (function (_super) {
6762
});
6863
return _this;
6964
}
70-
Object.defineProperty(PublicArray.prototype, "copy", {
71-
// this.copy -- returns independent copy of 'this', not linked to 'this' in any way.
72-
get: function () {
73-
// @ts-ignore
74-
return di_factory_1.DIFactory.getInstance(PublicArray, [this.get.copy()]);
75-
},
76-
enumerable: true,
77-
configurable: true
78-
});
65+
// changes the value of this.data without breaking its memory reference.
66+
PublicArray.prototype.set = function (newArray) {
67+
set_array_1.setArray(this.data, newArray);
68+
};
7969
PublicArray.prototype.append = function (values) {
8070
return this.returnThis_after(array_append_prepend_1.append(values, this.data));
8171
};
@@ -85,10 +75,6 @@ var PublicArray = /** @class */ (function (_super) {
8575
PublicArray.prototype.forEach = function (iterationFunction) {
8676
return this.returnThis_after(this.data.forEach(iterationFunction));
8777
};
88-
// Use this to change the value of this.data without breaking its memory reference.
89-
PublicArray.prototype.set = function (newArray) {
90-
return this.returnThis_after(set_array_1.setArray(this.data, newArray));
91-
};
9278
return PublicArray;
9379
}(public_array_content_1.PublicArrayContent));
9480
exports.PublicArray = PublicArray;

dist/tests.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

lib/index.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,14 @@ import { PublicArrayContent } from '@writetome51/public-array-content';
1111
The main reason you would use this class is if you hate JavaScript's built-in Array
1212
methods, like .slice(), .splice(), .push(), and .shift(). This class has much clearer
1313
and expressive method names, and a lot more of them.
14-
15-
A few examples of usage:
16-
17-
let arr = getPublicArray([1,2,3,4,5,6]);
18-
arr.remove.tail(2); // arr.data is now [1,2,3,4]
19-
if (arr.notEmpty) arr.prepend([10]); // arr.data is now [10,1,2,3,4]
2014
**********************/
2115

2216

2317
export class PublicArray extends PublicArrayContent {
2418

2519

26-
// readonly copy: PublicArray (an independent copy of this instance).
20+
// These are all created with getter functions in the constructor.
21+
2722
readonly filter; // PublicArrayFilter
2823
readonly getConverted; // PublicArrayGetterConverter;
2924
readonly get; // PublicArrayGetter;
@@ -34,6 +29,8 @@ export class PublicArray extends PublicArrayContent {
3429
readonly sort; // PublicArraySorter;
3530

3631

32+
// These are all instances gotten from dependencyClasses in the constructor.
33+
3734
private _filter; // PublicArrayFilter
3835
private _getConverted; // PublicArrayGetterConverter
3936
private _get; // PublicArrayGetter
@@ -50,6 +47,8 @@ export class PublicArray extends PublicArrayContent {
5047

5148
super(data);
5249

50+
// These are not loaded at the top with import statements because we're loading them
51+
// lazily in the getter functions to boost performance.
5352
let dependencyClasses = [
5453
{path: '@writetome51/public-array-filter', name: 'PublicArrayFilter'},
5554
{path: '@writetome51/public-array-getter-converter', name: 'PublicArrayGetterConverter'},
@@ -63,12 +62,13 @@ export class PublicArray extends PublicArrayContent {
6362

6463
this._createGetterAndOrSetterForEach(
6564
// each of these is a public property:
66-
['filter', 'getConverted', 'get', 'getAndRemove', 'insert',
67-
'remove', 'replace', 'sort'],
65+
['filter', 'getConverted', 'get', 'getAndRemove', 'insert', 'remove', 'replace', 'sort'],
66+
6867
{
6968
get_getterFunction: (property, index) => {
7069
return () => {
71-
// Lazy-Loading is used to instantiate these properties:
70+
71+
// Lazy-Loading is used to instantiate each property:
7272
if (!(this[`_${property}`])) { // if property not set...
7373
let dependencyClass = dependencyClasses[index];
7474
// @ts-ignore
@@ -84,10 +84,10 @@ export class PublicArray extends PublicArrayContent {
8484
}
8585

8686

87-
// this.copy -- returns independent copy of 'this', not linked to 'this' in any way.
88-
get copy(): PublicArray {
89-
// @ts-ignore
90-
return DIFactory.getInstance(PublicArray, [this.get.copy()]);
87+
// changes the value of this.data without breaking its memory reference.
88+
89+
set(newArray): void {
90+
setArray(this.data, newArray);
9191
}
9292

9393

@@ -106,10 +106,4 @@ export class PublicArray extends PublicArrayContent {
106106
}
107107

108108

109-
// Use this to change the value of this.data without breaking its memory reference.
110-
set(newArray): this {
111-
return this.returnThis_after(setArray(this.data, newArray));
112-
}
113-
114-
115109
}

package-lock.json

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
"dependencies": {
3333
"@writetome51/public-array-remover": "~1.0.1",
34-
"@writetome51/public-array-content": "~1.0.4",
34+
"@writetome51/public-array-content": "~1.2.0",
3535
"@writetome51/public-array-getter": "~1.0.1",
3636
"@writetome51/public-array-inserter": "~2.0.0",
3737
"@writetome51/public-array-sorter": "~1.0.0",
@@ -41,6 +41,6 @@
4141
"@writetome51/public-array-filter": "~1.0.5",
4242
"@writetome51/array-append-prepend": "~1.0.3",
4343
"@writetome51/di-factory": "~1.0.0",
44-
"@writetome51/set-array": "~1.0.0"
44+
"@writetome51/set-array": "~1.0.1"
4545
}
4646
}

0 commit comments

Comments
 (0)