1.0.7 • Published 4 years ago

arrayify.js v1.0.7

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

This Package is for front-end!

Arrayify js!

a library for creating arrays with cross browser support Its fast as its default and it includes some other helpful methods like Duplicate & Chain & Renamed Methods support!

Files

When you download the package it has two files wich is:

  1. Arrayify.js
  2. Arrayify.min.js

Using

The main Object is Arrayify:

 var array = new Arrayify([...arg]);

Like Array Object is has length and another property that is unique: Duplicate here is a simple example:

var array = new Arrayify(1, 2, 3, 4, 5, 6): { 0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6 }; => {0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6, length: 6, duplicate: false}

Renamed Methods

this methods are available but with its renamed function |original| renamed | |--|--| |push|addEnd| |unshift| addStart | |slice|count| |forEach|each| |includes|hasItem| |filter|findAll| |find|findOne|

Other Methods

This Library supports every methods that Array object does. but it has some methods which is not included like:

Arrayify. is( arrayLike ) : boolean

Arrayify.is( [1, 2, 4, 5, 6] ) // <= if arraylikes items equal this items returns true
.> true

Arrayify. isThisType( arg ) : boolean

Arrayify.isThisType( new Arrayify(1,2,3) ) // <= if argument has same type as this returns true
.> true

Arrayify. is ArrayLike( arg )

Arrayify.isArrayLike({ length: 0, splice: function() {} }) // <= jQuery returns true
.> true

array.unconcat( arrayLike ): ThisType

var array = new Arrayify(1, 2, 3, 4).unconcat([ 1, 2, 3 ])
.> [ 4 ]

array. removeItems(...arg): ThisType;

var array = new Arrayify(1, 2, 3, 4, 5, 6).removeItems( 1,2 )
.> [3, 4, 5, 6]

array . addBefore( index, ...arg ): ThisType;

var array = new Arrayify(1, 2, 3, 4, 5, 6).addBefore( 1 , 1.25, 1.5, 1.75);
.> [1, 1.25, 1.5, 1.75, 2, 3, 4, 5, 6];

another Method wich has a property ( and inherited to children ):

Arrayify. duplicate = boolean Arrayify. acceptDuplicate( boolean ): ThisType

Duplicate Methods

When an object creates it has a property wich is inherited from Arrayify Object: duplicate: true/false this value is false by default even you changed it with two ways:

var array = new Arrayify(1, 2);
array.duplicate = true/false;
array.acceptDuplicate( true/false )

Even You change this property in Parent with: Arrayify.acceptDuplicate(false) this inherites to children and when you passed or add an item wich is repeated it will remove from the array:

Arrayify.duplicate = false;

var array = new Arrayify(1, 2, 2, 3, 3, 4, 5, 6);
.> [ 1, 2, 3, 4, 5, 6 ]

array.addEnd(4,3,5,6,7)
.> [1, 2, 3, 4, 5, 6, 7]

Warning: Changing main Object duplicate property will effect just to new Objects that does not have defined yet!

var array = new Arrayify(1, 2, 3, 4, 5, 6,6);
.> [1,2,3,4,5,6,6]
Arrayify.acceptDuplicate(false)

var newArray = new Arrayify(1, 2, 3, 4, 5, 6, 6)
.> [1, 2, 3, 4, 5, 6]

Thanks for choose this Library if you found any error or bugs please tell me:

mohammadmahdi1383@outlook.com

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago