jQuery Collection

码农软件 · 软件分类 · 其他jQuery插件 · 2020-01-10 15:56:36

软件介绍

This plugin generates generic collection classes, that work almost exactly as jQuery does.
These collections include all those jQuery functions, that are used to manipulate the collection itself.

The included built-in functions are:

add, andSelf, attr, each, end, eq, extend, filter, get, implement, include, index, init, is, map, not, pushStack, setArray, size and slice.


Every collection will have a build() function, that will create a new collection class, that inherits from the caller. $.collection is a collection class by itself. So other collections will inherit from it, or its subclasses.

With this plugin, you can manipulate native data types like String or Array, with your custom methods, without actually modifying their prototype. This is shown in some of the examples below.

If you want additional information and more details about some of the methods.
Check this explanatory text, also included in the release.

Examples

$.collection(1,2,3,4).filter([2,3]).eq(1);//--> [ 3 ]


$.number = $.collection.build();
$.number.fn.sum = function(){
    var n = 0;
    this.each(function(){ n += this; });
    return n;
};
$.number(1,2,3,4).add(5).not(function(){
    return this <= 2;
}).sum();//yields --> 12 ( 3 + 4 + 5 )


$.array = $.collection.build();
$.array.fn.include( Array.prototype, &#039;join,push&#039; );
var $arr = $.array(&#039;I&#039;,&#039;like&#039;,&#039;xyz&#039;,&#039;jQuery&#039;).add(&#039;very&#039;).not(&#039;xyz&#039;);
$arr.push( &#039;much&#039; );
$arr.join(&#039; &#039;);// yields --> &#039;I like jQuery very much&#039;


var Nodes = $.collection.build();
Nodes.fn.init = function( elems ){
    elems = document.getElementsByTagName(elems);
    return this.setArray( $.makeArray(elems) );
};
Nodes(&#039;body&#039;).add(&#039;script&#039;).attr(&#039;className&#039;,&#039;node&#039;);//-->[ <body>, <script>, <script> ]


var MyString = $.collection.build();
MyString.implement( String.prototype, &#039;replace,toUpperCase&#039;);
MyString(&#039;jQuery&#039;,&#039;Quack&#039;).replace(&#039;Q&#039;,&#039;X&#039;).toUpperCase()// --> [ &#039;JXUERY&#039;, &#039;XUACK&#039; ]

Please, make sure to upgrade to 1.0.3
The plugin is very easy to master and is relatively small, less than 2KB packed

本文地址:https://codercto.com/soft/d/23084.html

科技想要什么

科技想要什么

[美] 凯文·凯利 / 熊祥 / 中信出版社 / 2011-11 / 58.00元

在《科技想要什么》一书中,凯文•凯利向我们介绍了一种全新的科技观。他认为,作为整体,科技不是由线路和金属构成的一团乱麻,而是有生命力的自然形成的系统,它的起源完全可以回溯到生命的初始时期。正如生物进化呈现出无意识的趋势,科技也是如此。通过追踪这些长期趋势,我们可以对“科技想要什么”有所理解。 凯文•凯利预测了未来数十年科技的12种趋势,包括创造大脑这一得寸进尺之举。不过,为了让人类创造的世界......一起来看看 《科技想要什么》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具