mirror of
https://bitbucket.org/bellord13/kit.git
synced 2026-11-13 19:06:11 +03:00
fx
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
/** @module collection */
|
||||
/**
|
||||
* в разработке
|
||||
*/
|
||||
kit.PluginManager.register('Collection',function(module, exports, require, global) {
|
||||
|
||||
var support = require('support');
|
||||
@@ -42,7 +45,7 @@ kit.PluginManager.register('Collection',function(module, exports, require, globa
|
||||
/**
|
||||
* @param key
|
||||
* @param value
|
||||
* @return {kitCore.Collection}
|
||||
* @return {kit.Collection}
|
||||
*/
|
||||
Collection.prototype.set = Collection.prototype.put = function (key, value) {
|
||||
this.data[key] = value;
|
||||
@@ -50,7 +53,7 @@ kit.PluginManager.register('Collection',function(module, exports, require, globa
|
||||
};
|
||||
/**
|
||||
* @param value
|
||||
* @return {kitCore.Collection}
|
||||
* @return {kit.Collection}
|
||||
*/
|
||||
Collection.prototype.push = function (value) {
|
||||
if(this.type === 'Array') {
|
||||
@@ -77,7 +80,7 @@ kit.PluginManager.register('Collection',function(module, exports, require, globa
|
||||
};
|
||||
/**
|
||||
* @param callback
|
||||
* @return {kitCore.Collection}
|
||||
* @return {kit.Collection}
|
||||
*/
|
||||
Collection.prototype.map = function (callback) {
|
||||
var res = getSimilarInstance(this.type);
|
||||
@@ -88,7 +91,7 @@ kit.PluginManager.register('Collection',function(module, exports, require, globa
|
||||
};
|
||||
/**
|
||||
* @param callback
|
||||
* @return {kitCore.Collection}
|
||||
* @return {kit.Collection}
|
||||
*/
|
||||
Collection.prototype.each = function (callback = true) {
|
||||
var BreakException = {}, keys, i, key;
|
||||
@@ -108,7 +111,7 @@ kit.PluginManager.register('Collection',function(module, exports, require, globa
|
||||
};
|
||||
/**
|
||||
* @param callback
|
||||
* @return {kitCore.Collection}
|
||||
* @return {kit.Collection}
|
||||
*/
|
||||
Collection.prototype.eachReverse = function (callback = true) {
|
||||
var BreakException = {}, keys, i, key;
|
||||
@@ -128,7 +131,7 @@ kit.PluginManager.register('Collection',function(module, exports, require, globa
|
||||
};
|
||||
/**
|
||||
* @param callback
|
||||
* @return {kitCore.Collection}
|
||||
* @return {kit.Collection}
|
||||
*/
|
||||
Collection.prototype.filter = function (callback = filter) {
|
||||
var res = getSimilarInstance(this.type);
|
||||
@@ -186,14 +189,34 @@ kit.PluginManager.register('Collection',function(module, exports, require, globa
|
||||
});
|
||||
return res;
|
||||
};
|
||||
Collection.prototype.forget = function (key) {
|
||||
key = '' + valueEx(key);
|
||||
if(!this.has(key)) {
|
||||
return this;
|
||||
}
|
||||
switch (this.type) {
|
||||
case 'Array':
|
||||
case 'object':
|
||||
delete this.data[key];
|
||||
break;
|
||||
case 'NodeList':
|
||||
var newCollection = this.filter(function (v, k, arr) {
|
||||
return key !== Number(k).toString();
|
||||
});
|
||||
this.data = newCollection.data;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
return this;
|
||||
};
|
||||
/**
|
||||
* @return {kitCore.Collection}
|
||||
* @return {kit.Collection}
|
||||
*/
|
||||
Collection.prototype.keys = function () {
|
||||
return new Collection(Object.keys(this.data));
|
||||
};
|
||||
/**
|
||||
* @return {kitCore.Collection}
|
||||
* @return {kit.Collection}
|
||||
*/
|
||||
Collection.prototype.dump = Collection.prototype.dd = function () {
|
||||
console.log('Collection', this.data);
|
||||
|
||||
Reference in New Issue
Block a user