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 */
|
/** @module collection */
|
||||||
|
/**
|
||||||
|
* в разработке
|
||||||
|
*/
|
||||||
kit.PluginManager.register('Collection',function(module, exports, require, global) {
|
kit.PluginManager.register('Collection',function(module, exports, require, global) {
|
||||||
|
|
||||||
var support = require('support');
|
var support = require('support');
|
||||||
@@ -42,7 +45,7 @@ kit.PluginManager.register('Collection',function(module, exports, require, globa
|
|||||||
/**
|
/**
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
* @return {kitCore.Collection}
|
* @return {kit.Collection}
|
||||||
*/
|
*/
|
||||||
Collection.prototype.set = Collection.prototype.put = function (key, value) {
|
Collection.prototype.set = Collection.prototype.put = function (key, value) {
|
||||||
this.data[key] = value;
|
this.data[key] = value;
|
||||||
@@ -50,7 +53,7 @@ kit.PluginManager.register('Collection',function(module, exports, require, globa
|
|||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @param value
|
* @param value
|
||||||
* @return {kitCore.Collection}
|
* @return {kit.Collection}
|
||||||
*/
|
*/
|
||||||
Collection.prototype.push = function (value) {
|
Collection.prototype.push = function (value) {
|
||||||
if(this.type === 'Array') {
|
if(this.type === 'Array') {
|
||||||
@@ -77,7 +80,7 @@ kit.PluginManager.register('Collection',function(module, exports, require, globa
|
|||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @param callback
|
* @param callback
|
||||||
* @return {kitCore.Collection}
|
* @return {kit.Collection}
|
||||||
*/
|
*/
|
||||||
Collection.prototype.map = function (callback) {
|
Collection.prototype.map = function (callback) {
|
||||||
var res = getSimilarInstance(this.type);
|
var res = getSimilarInstance(this.type);
|
||||||
@@ -88,7 +91,7 @@ kit.PluginManager.register('Collection',function(module, exports, require, globa
|
|||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @param callback
|
* @param callback
|
||||||
* @return {kitCore.Collection}
|
* @return {kit.Collection}
|
||||||
*/
|
*/
|
||||||
Collection.prototype.each = function (callback = true) {
|
Collection.prototype.each = function (callback = true) {
|
||||||
var BreakException = {}, keys, i, key;
|
var BreakException = {}, keys, i, key;
|
||||||
@@ -108,7 +111,7 @@ kit.PluginManager.register('Collection',function(module, exports, require, globa
|
|||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @param callback
|
* @param callback
|
||||||
* @return {kitCore.Collection}
|
* @return {kit.Collection}
|
||||||
*/
|
*/
|
||||||
Collection.prototype.eachReverse = function (callback = true) {
|
Collection.prototype.eachReverse = function (callback = true) {
|
||||||
var BreakException = {}, keys, i, key;
|
var BreakException = {}, keys, i, key;
|
||||||
@@ -128,7 +131,7 @@ kit.PluginManager.register('Collection',function(module, exports, require, globa
|
|||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @param callback
|
* @param callback
|
||||||
* @return {kitCore.Collection}
|
* @return {kit.Collection}
|
||||||
*/
|
*/
|
||||||
Collection.prototype.filter = function (callback = filter) {
|
Collection.prototype.filter = function (callback = filter) {
|
||||||
var res = getSimilarInstance(this.type);
|
var res = getSimilarInstance(this.type);
|
||||||
@@ -186,14 +189,34 @@ kit.PluginManager.register('Collection',function(module, exports, require, globa
|
|||||||
});
|
});
|
||||||
return res;
|
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 () {
|
Collection.prototype.keys = function () {
|
||||||
return new Collection(Object.keys(this.data));
|
return new Collection(Object.keys(this.data));
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @return {kitCore.Collection}
|
* @return {kit.Collection}
|
||||||
*/
|
*/
|
||||||
Collection.prototype.dump = Collection.prototype.dd = function () {
|
Collection.prototype.dump = Collection.prototype.dd = function () {
|
||||||
console.log('Collection', this.data);
|
console.log('Collection', this.data);
|
||||||
|
|||||||
@@ -2,6 +2,14 @@
|
|||||||
<script src="../assets/core/core.js"></script>
|
<script src="../assets/core/core.js"></script>
|
||||||
<script src="../assets/core/core.register.js"></script>
|
<script src="../assets/core/core.register.js"></script>
|
||||||
|
|
||||||
|
<?
|
||||||
|
$x = [];
|
||||||
|
|
||||||
|
$x[10] = 10;
|
||||||
|
$x[1] = 1;
|
||||||
|
print_r($x);
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
Reference in New Issue
Block a user