This commit is contained in:
2022-05-30 17:50:04 +03:00
parent 2a6f01f460
commit a44faad823
26 changed files with 772 additions and 393 deletions
+17 -17
View File
@@ -13,7 +13,7 @@ kit.PluginManager.register('Collection', function(module, exports, require, glob
}
/**
* @param type
* @return {kit.Collection}
* @return {Collection}
*/
function getSimilarInstance(type) {
if(type === 'object') {
@@ -25,7 +25,7 @@ kit.PluginManager.register('Collection', function(module, exports, require, glob
/**
* @class Collection
* @property length
* @memberOf kit
* @memberOf {kit}
*/
var Collection = function (data = []) {
var self = this;
@@ -114,7 +114,7 @@ kit.PluginManager.register('Collection', function(module, exports, require, glob
/**
* @param key
* @param value
* @return {kit.Collection}
* @return {Collection}
*/
Collection.prototype.add = Collection.prototype.set = Collection.prototype.put = function (key, value) {
var index = -1;
@@ -128,7 +128,7 @@ kit.PluginManager.register('Collection', function(module, exports, require, glob
};
/**
* @param value
* @return {kit.Collection}
* @return {Collection}
*/
Collection.prototype.push = function (value) {
this.set(this.__getLastIndex() + 1, value);
@@ -151,7 +151,7 @@ kit.PluginManager.register('Collection', function(module, exports, require, glob
* возвращает новый экземпляр коллекции; не изменяет вызываемую коллекцию
*
* @param callback
* @return {kit.Collection}
* @return {Collection}
*/
Collection.prototype.map = function (callback) {
var res = getSimilarInstance(this.__type);
@@ -165,7 +165,7 @@ kit.PluginManager.register('Collection', function(module, exports, require, glob
};
/**
* @param callback
* @return {kit.Collection}
* @return {Collection}
*/
Collection.prototype.each = function (callback = true) {
var i;
@@ -179,7 +179,7 @@ kit.PluginManager.register('Collection', function(module, exports, require, glob
};
/**
* @param callback
* @return {kit.Collection}
* @return {Collection}
*/
Collection.prototype.eachReverse = function (callback = true) {
var i;
@@ -193,7 +193,7 @@ kit.PluginManager.register('Collection', function(module, exports, require, glob
};
/**
* @param callback
* @return {kit.Collection}
* @return {Collection}
*/
Collection.prototype.filter = function (callback = filter) {
var res = getSimilarInstance(this.__type);
@@ -208,7 +208,7 @@ kit.PluginManager.register('Collection', function(module, exports, require, glob
/**
* Метод возвращает все элементы коллекции, кроме тех у кого ключи соответствуют заданным
* @param keys
* @return {kit.Collection}
* @return {Collection}
*/
Collection.prototype.except = function (keys) {
var __keys = [], iKey;
@@ -227,7 +227,7 @@ kit.PluginManager.register('Collection', function(module, exports, require, glob
/**
* Метод возвращает элементы коллекции с заданными ключами
* @param keys
* @return {kit.Collection}
* @return {Collection}
*/
Collection.prototype.only = function (keys) {
var __keys = [], iKey;
@@ -294,7 +294,7 @@ kit.PluginManager.register('Collection', function(module, exports, require, glob
/**
* Method removes/delete an item from the collection by its key
* @param key
* @return {kit.Collection}
* @return {Collection}
*/
Collection.prototype.forget = function (key) {
key = valueEx(key);
@@ -311,7 +311,7 @@ kit.PluginManager.register('Collection', function(module, exports, require, glob
* Method removes and returns an item from the collection by its key
* @param key
* @param defValue
* @return {kit.Collection}
* @return {Collection}
*/
Collection.prototype.pull = function (key, defValue = undefined) {
key = valueEx(key);
@@ -356,20 +356,20 @@ kit.PluginManager.register('Collection', function(module, exports, require, glob
return value;
};
/**
* @return {kit.Collection}
* @return {Collection}
*/
Collection.prototype.keys = function () {
return new Collection(Object.keys(this.data));
};
/**
* @return {kit.Collection}
* @return {Collection}
*/
Collection.prototype.dump = function () {
console.log('Collection', this.data);
return this;
};
/**
* @return {kit.Collection}
* @return {Collection}
*/
Collection.prototype.dd = function () {
this.dump();
@@ -377,7 +377,7 @@ kit.PluginManager.register('Collection', function(module, exports, require, glob
return this;
};
/**
* @return {kit.Collection}
* @return {Collection}
*/
Collection.prototype.eachCall = function (context, args1, args2) {
var args = [], i;
@@ -446,7 +446,7 @@ kit.PluginManager.register('Collection', function(module, exports, require, glob
* Значения в коллекци должны быть массиво подобные
*
* @param key
* @return {kit.Collection}
* @return {Collection}
*/
Collection.prototype.pluck = function (key) {
return this.map(function (value) {