File tree Expand file tree Collapse file tree 3 files changed +29
-17
lines changed Expand file tree Collapse file tree 3 files changed +29
-17
lines changed Original file line number Diff line number Diff line change @@ -4,12 +4,20 @@ A tiny JavaScript utility library.
44
55## 简介
66
7- 一个非常小巧的 JavaScript 工具库,适用于用户脚本(userscript) 、演示案例等比较紧凑的场景。
7+ 一个非常小巧的 JavaScript 工具库,适用于用户脚本、演示案例等比较紧凑的场景。
88
99因为使用了一些较先进的 JavaScript/DOM API,仅适用于现代浏览器。
1010
1111** 注意** :仍在开发中,API 仍不稳定。
1212
13+ ## 安装
14+
15+ ``` bash
16+ $ bower install tiny.js
17+ ```
18+
19+ ***
20+
1321## License
1422
1523[ MIT License] ( http://www.opensource.org/licenses/mit-license.php )
Original file line number Diff line number Diff line change 1111 " globals"
1212 ],
1313 "keywords" : [
14- " weibo" ,
15- " v5"
14+ " JavaScript" ,
15+ " utility" ,
16+ " library"
1617 ],
1718 "license" : " MIT" ,
1819 "ignore" : [
Original file line number Diff line number Diff line change 11/*!
2- * Tiny.js
2+ * Tiny.js v0.4.0
33 * https://github.com/UserScript/tiny.js
44 */
55
6- void function ( ) {
6+ void function ( root ) {
77 'use strict'
88
99 //namespace
1010 var $ = function ( s , eWrapper ) {
1111 return ( eWrapper || document ) . querySelectorAll ( s )
1212 }
1313
14- //utilities
14+ //type
15+ $ . isArray = function ( arr ) {
16+ return Array . isArray ( arr )
17+ }
18+
19+ //data collection
1520 //TODO
1621 //$.extend()
17- $ . each = function ( a , fn , context ) {
22+ $ . each = function ( arr , fn , context ) {
1823 //todo: object
19- for ( var i = 0 , l = a . length ; i < l ; ++ i ) {
20- fn . call ( context || window , a [ i ] , i , a )
24+ for ( var i = 0 , l = arr . length ; i < l ; ++ i ) {
25+ fn . call ( context || window , arr [ i ] , i , arr )
2126 }
2227 }
28+ $ . inArray = function ( arr , item ) {
29+ if ( ! $ . isArray ( arr ) ) return false
30+ return arr . indexOf ( item ) > - 1
31+ }
2332
2433 //str
2534 $ . str = { }
@@ -122,12 +131,6 @@ void function () {
122131 }
123132
124133 //exports
125- if (
126- ! ( 'jQuery' in window ) &&
127- ! ( 'Zepto' in window ) &&
128- ! ( '$' in window )
129- ) {
130- window . $ = $
131- }
134+ root . $ = $
132135
133- } ( )
136+ } ( this )
You can’t perform that action at this time.
0 commit comments