- 浏览: 186671 次
- 性别:
- 来自: 湖州
最新评论
-
l_zh_y:
非常 感谢
spket-1.6.11.zip破解版-eclipse插件links方式安装包 -
nookiehuihui:
非常感谢 一直在找破解的
spket-1.6.11.zip破解版-eclipse插件links方式安装包 -
bangyan2003:
要破解的 这东西?????
spket-1.6.11.zip破解版-eclipse插件links方式安装包 -
oyhf521:
非常感谢啊,顶,就一个字
spket-1.6.11.zip破解版-eclipse插件links方式安装包 -
xiezhuogang:
哈哈,谢谢了
spket-1.6.11.zip破解版-eclipse插件links方式安装包
js 代码
- var $break = new Object(); //表示break的对象 可以对比java的exception的使用
- var $continue = new Object(); //表示continue的对象 可以对比java的exception的使用
- var Enumerable = {
- each: function(iterator) { //执行_each函数
- var index = 0;
- try {
- this._each(function(value) {
- try {
- iterator(value, index++);
- } catch (e) {
- if (e != $continue) throw e;
- }
- });
- } catch (e) {
- if (e != $break) throw e;
- }
- },
- //boolean 返回函数遍历执行后的总结果 如果每次执行都返回非假则得到true
- all: function(iterator) {
- var result = true;
- this.each(function(value, index) {
- result = result && !!(iterator || Prototype.K)(value, index);
- if (!result) throw $break;
- });
- return result;
- },
- //boolean 返回函数遍历执行后的总结果 只要遇到执行返回非假则得到true
- any: function(iterator) {
- var result = true;
- this.each(function(value, index) {
- if (result = !!(iterator || Prototype.K)(value, index))
- throw $break;
- });
- return result;
- },
- //result array 把函数遍历执行后的结果放进一个数组返回
- collect: function(iterator) {
- var results = [];
- this.each(function(value, index) {
- results.push(iterator(value, index));
- });
- return results;
- },
- // 返回any函数中执行非假的那个参数value
- detect: function (iterator) {
- var result;
- this.each(function(value, index) {
- if (iterator(value, index)) {
- result = value;
- throw $break;
- }
- });
- return result;
- },
- // 针对collect函数进行过滤 只有执行非假的函数参数value才进入结果数组
- findAll: function(iterator) {
- var results = [];
- this.each(function(value, index) {
- if (iterator(value, index))
- results.push(value);
- });
- return results;
- },
- // 针对collect函数进行过滤 只有执行value符合pattern,才把执行结果进入结果数组
- grep: function(pattern, iterator) {
- var results = [];
- this.each(function(value, index) {
- var stringValue = value.toString();
- if (stringValue.match(pattern))
- results.push((iterator || Prototype.K)(value, index));
- })
- return results;
- },
- //boolean 是否为value的数组的成员
- include: function(object) {
- var found = false;
- this.each(function(value) {
- if (value == object) {
- found = true;
- throw $break;
- }
- });
- return found;
- },
- //通过注入inject 累及运算结果进行 累计运算
- inject: function(memo, iterator) {
- this.each(function(value, index) {
- memo = iterator(memo, value, index);
- });
- return memo;
- },
- //传递 函数+需要的参数 进行遍历执行 并返回执行结果集
- invoke: function(method) {
- var args = $A(arguments).slice(1);
- return this.collect(function(value) {
- return value[method].apply(value, args);
- });
- },
- // 取函数遍历执行后 最大的返回值
- max: function(iterator) {
- var result;
- this.each(function(value, index) {
- value = (iterator || Prototype.K)(value, index);
- if (value >= (result || value))
- result = value;
- });
- return result;
- },
- // 取函数遍历执行后 最小的返回值
- min: function(iterator) {
- var result;
- this.each(function(value, index) {
- value = (iterator || Prototype.K)(value, index);
- if (value <= (result || value))
- result = value;
- });
- return result;
- },
- //把执行结果按照true 和 非true 作为2维数组返回
- partition: function(iterator) {
- var trues = [], falses = [];
- this.each(function(value, index) {
- ((iterator || Prototype.K)(value, index) ?
- trues : falses).push(value);
- });
- return [trues, falses];
- },
- // 遍历数组取每个元素的该属性值放进结果数组返回
- pluck: function(property) {
- var results = [];
- this.each(function(value, index) {
- results.push(value[property]);
- });
- return results;
- },
- //返回遍历执行函数iterator结果非真的元素的结合
- reject: function(iterator) {
- var results = [];
- this.each(function(value, index) {
- if (!iterator(value, index))
- results.push(value);
- });
- return results;
- },
- //返回排序函数执行后的排序结果集
- sortBy: function(iterator) {
- return this.collect(function(value, index) {
- return {value: value, criteria: iterator(value, index)};
- }).sort(function(left, right) {
- var a = left.criteria, b = right.criteria;
- return a < b ? -1 : a > b ? 1 : 0;
- }).pluck('value');
- },
- //可遍历集合转换成js数组
- toArray: function() {
- return this.collect(Prototype.K);
- },
- //zip压缩
- zip: function() {
- var iterator = Prototype.K, args = $A(arguments);
- if (typeof args.last() == 'function')
- iterator = args.pop();
- var collections = [this].concat(args).map($A);
- return this.map(function(value, index) {
- iterator(value = collections.pluck(index));
- return value;
- });
- },
- //查看 类似tostring
- inspect: function() {
- return '#this.toArray().inspect() + '>';
- }
- }
- Object.extend(Enumerable, {
- map: Enumerable.collect,
- find: Enumerable.detect,
- select: Enumerable.findAll,
- member: Enumerable.include,
- entries: Enumerable.toArray
- });
待完善,欢迎指点、意见、建议。
发表评论
-
【Extjs学习七】Extjs2.0 日期相关函数
2009-03-02 11:22 1127主要是parse 到date 和 format到string -
【Extjs学习七】Extjs2.0 form如何使用checkbox和radiobox
2009-02-27 08:59 4292问题:Extjs2.0 form如何使用checkbox和ra ... -
在Ext中如何使窗体总在最前面(how to set a window always on top
2009-01-23 17:10 1636http://hi.baidu.com/rainchen/bl ... -
【Extjs学习七】extjs2-淘宝特效代码实践
2008-09-26 09:56 2525学习extjs拿网站特效练了练手,是在 http://www. ... -
【Extjs学习六】extjs2-element全面分析
2008-09-11 19:51 2524分析图标见附件excel表格,大家可以可通过数据帅选等方式自行 ... -
spket-1.6.11.zip破解版-eclipse插件links方式安装包
2008-09-11 18:58 7791spket-1.6.11.zip破解版-eclipse插件li ... -
【Extjs学习五】Extjs2-lib源码分析图解
2008-09-10 08:33 1525针对ext-lib进行了大致的分析,画了个简单的类图,给我的感 ... -
【Extjs学习四】Extjs2事件机制源码分析图解
2008-09-09 15:51 3326http://www.iteye.com/topic/1569 ... -
Extjs2.2 已经开始抛弃其他框架了吗?
2008-09-08 19:05 1048如题: 我看到在ext-base中ext.lib.event有 ... -
【Extjs学习三】Extjs2使用心得摘录
2008-07-17 09:35 1227080717 Ext.data.JsonStore的必要参 ... -
【Extjs学习二】Extjs2小控件slideplayer
2008-07-04 17:10 2738这下子左右上下的tab都可以轻松添加到web页面上去了,目前没 ... -
【Extjs学习一】Extjs2继承函数简单分析及疑问
2008-05-21 19:48 3563Ext = {version: '2.0'}; ... -
摘录的文章
2008-05-14 19:10 806http://www.cnblogs.com/leadzen/ ... -
给javascript library挑挑刺
2007-05-16 10:59 6577第一个观点:(js代码不仅仅是为了实现功能而且是拿来给程序员看 ... -
I Love javascript
2007-04-02 22:58 110学习javascript是一个长期的过程,解释型弱类型动态语言 ... -
【prototype学习】基于prototype的tree(纯数据驱动OO)
2006-12-30 20:19 3057rt: 给出代码和demo; 看到很多tree的实现,很少有数 ... -
【prototype学习】基于prototype的拖动以及3横2竖布局
2006-12-25 16:25 4060rt ps: 学习prototype ing,参考着做了 ... -
【prototype学习】基于prototype的表单验证(二)
2006-12-12 16:26 16220上次在javaEye上看到了一 ... -
【prototype学习】基于prototype的表单验证(一)
2006-11-28 10:20 12097前台的表单验证是项目必不可少的一个部分,可以说是WEB项目很重 ... -
我的javascript学习之路(三) 对象之this
2006-09-16 12:10 4944主题:"this" of Ja ...
相关推荐
Enumerable是Prototype框架的基石,而Enumerable不单独使用,在Prototype中其它对象mix了Enumerable里面的方法,这样就可以在这些对象上应用Enumerable的方法,这样的对象有:Array,Hash,ObjectRange,还有一些和...
Enumerable是一个抽象对象(需要说明的是,javascript中并没有类的概念,所指的类也就是一个函数,继承一般指的是一个对象(父)将它的方法属性copy(通过Object.extend, copy的是引用)到子类(函数)的prototype属性(一...
在javascript中,根本找不到Enumerable的影子,因为这一块是Prototype作者从Ruby中借鉴过来的。并且Enumerable在实际中根本没有直接应用的机会,都是混入到其他的对象中,可以说是其他对象的一个“父类”(不过只是...
剩下的方法太多,于是分作两部分。亮点就是$break和$continue,以及grep方法的思想
前端开源库-node-enumerable节点可枚举,ES6就绪LINQ功能以typescript编写
根据AsyncEnumerator的原理改写,提供了线程函数的流程控制,线程管理,监视函数调用超时的功能。 适用于需要开启多个线程,要去线程能够长时间稳定执行某一操作的场景 不足之处欢迎留言
Recursively Enumerable Sets and Degrees by Rovert I. Soare。递归论的书籍,Soare的,从djvu转过来的,有可能有误。经典的教材
prototype 精妙的文档 • Extensions for the Object class • Extensions for the Number class • Extensions for the Function class • Extensions for the String class ...• The Enumerable object
将iterable转化为数组,如果iterable定义了toArray方法,就调用这个方法,否则利用iterable的length属性进行枚举, 如果iterable没有length属性的话就返回空数组[] Array对象除了扩展Enumerable对象的方法外,...
CSharp 4.0 .Net Framework V4.0 Enumerable 类
这个库很大程度上受到 Ruby 的 Enumerable 模块的启发,并借用了它的大量功能。 注意:这并不意味着是一个独立的库,而是要与具有.each方法的另一种数据类型结合使用。安装作为 NPM 模块npm install enumerable-js ...
var Hash = Class.create(Enumerable, (function() { //初始化,创建一个新的Hash对象 function initialize(object) { this._object = Object.isHash(object) ? object.toObject() : Object.clone(object); } //...
这是基于但使用Object.defineProperty(arguments.constructor.prototype, [functionName], {enumerable: false, configurable: true, value: [functionBody]})代替,以避免迭代时出现混乱。 Object....
ObjectRange对象基本就是实现了连续的数字或者字符串,其中只包含一个方法,include,判断某个数字...并且ObjectRange对象还混入了Enumerable的方法,所以可以直接在ObjectRange对象上调用Enumerable对象里面的方法。
local Enumerable = require ( ' enumerable ' ) collectionInstance = Enumerable. create ({ 1 , 2 , 3 , 4 , 5 }) secondElement = collectionInstance[ 2 ] collectionInstance: each ( function ( value , ...
该项目展示了Ruby Enumerable模块中方法的重建列表。 重写的Enumerable方法是: 每个-> my_each each_with_index-> my_each_with_index 选择-> my_select 全部? -> my_all? 任何? -> my_any? 没有...
主要介绍了C#的LINQ查询中Enumerable类方法的延迟与立即执行,LINQ语言集成查询可以让C#和VB以查询数据库相同的方式操作内存数据,需要的朋友可以参考下