This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var collection = new TSCore.Data.Collection<string>(['jake', 'billy', 'joey']); | |
collection.toArray(); | |
// ['jake', 'billy', 'joey'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var collection = new TSCore.Data.Collection([1, 2, 3, 4, 5]); | |
var diff = collection->diff([2, 4, 6, 8]); | |
diff->toArray(); | |
// [1, 3, 5] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var collection = new TSCore.Data.Collection<number>([1, 2, 3, 4]).each(value => { | |
// | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var collection = new TSCore.Data.Collection<number>([1, 2, 3, 4]); | |
collection.clear(); | |
collection.toArray(); | |
// [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var collection = new TSCore.Data.Collection<Product>([ | |
new Product(1, 'Desk'), | |
new Product(2, 'Chair') | |
]); | |
var plucked = collection.pluck('name'); | |
plucked.toArray(); | |
// ['Desk', 'Chair'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var collection = new TSCore.Data.Collection<number>([1, 2, 3, 4, 5]); | |
var multiplied = collection.map((item: number, key: number) => { | |
return item * 2; | |
}); | |
multiplied.toArray(); | |
// [2, 4, 6, 8, 10] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var collection = new TSCore.Data.Collection<number>([1, 2, 3, 4, 5]); | |
collection.transform((item: number, key: number) => { | |
return item * 2; | |
}); | |
collection.toArray(); | |
// [2, 4, 6, 8, 10] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var collection = new TSCore.Data.Collection<Book>([ | |
new Book("Hamlet", "Shakespeare", 1602), | |
new Book("Cymbeline", "Shakespeare", 1611), | |
new Book("The Tempest", "Shakespeare", 1611), | |
]); | |
collection.where({author: "Shakespeare", year: 1611}); | |
// [ | |
// {title: "Cymbeline", author: "Shakespeare", year: 1611}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var collection = new TSCore.Data.Collection<Book>([ | |
new Book("Hamlet", "Shakespeare", 1602), | |
new Book("Cymbeline", "Shakespeare", 1611), | |
new Book("The Tempest", "Shakespeare", 1611), | |
]); | |
collection.where({author: "Shakespeare", year: 1611}); | |
// [ | |
// {title: "Cymbeline", author: "Shakespeare", year: 1611}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var collection = new TSCore.Data.Collection<number>([1, 2, 3, 4]); | |
var filtered = collection.reject(value => { | |
return value > 2; | |
}); | |
filtered.toArray(); | |
// [1, 2] |