@@ -24,19 +24,15 @@ var public_array_content_1 = require("@writetome51/public-array-content");
24
24
The main reason you would use this class is if you hate JavaScript's built-in Array
25
25
methods, like .slice(), .splice(), .push(), and .shift(). This class has much clearer
26
26
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]
33
27
**********************/
34
28
var PublicArray = /** @class */ ( function ( _super ) {
35
29
__extends ( PublicArray , _super ) ;
36
30
function PublicArray ( data // the actual array, represented by inherited property this.data
37
31
) {
38
32
if ( data === void 0 ) { data = [ ] ; }
39
33
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.
40
36
var dependencyClasses = [
41
37
{ path : '@writetome51/public-array-filter' , name : 'PublicArrayFilter' } ,
42
38
{ path : '@writetome51/public-array-getter-converter' , name : 'PublicArrayGetterConverter' } ,
@@ -49,11 +45,10 @@ var PublicArray = /** @class */ (function (_super) {
49
45
] ;
50
46
_this . _createGetterAndOrSetterForEach (
51
47
// 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' ] , {
54
49
get_getterFunction : function ( property , index ) {
55
50
return function ( ) {
56
- // Lazy-Loading is used to instantiate these properties :
51
+ // Lazy-Loading is used to instantiate each property :
57
52
if ( ! ( _this [ "_" + property ] ) ) { // if property not set...
58
53
var dependencyClass = dependencyClasses [ index ] ;
59
54
// @ts -ignore
@@ -67,15 +62,10 @@ var PublicArray = /** @class */ (function (_super) {
67
62
} ) ;
68
63
return _this ;
69
64
}
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
+ } ;
79
69
PublicArray . prototype . append = function ( values ) {
80
70
return this . returnThis_after ( array_append_prepend_1 . append ( values , this . data ) ) ;
81
71
} ;
@@ -85,10 +75,6 @@ var PublicArray = /** @class */ (function (_super) {
85
75
PublicArray . prototype . forEach = function ( iterationFunction ) {
86
76
return this . returnThis_after ( this . data . forEach ( iterationFunction ) ) ;
87
77
} ;
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
- } ;
92
78
return PublicArray ;
93
79
} ( public_array_content_1 . PublicArrayContent ) ) ;
94
80
exports . PublicArray = PublicArray ;
0 commit comments