一个轻量级的JavaScript库:ICE
jopen
10年前
一个轻量级的JavaScript库:ICE。
ICE 特性:
- Small footprint (65KB uncompressed)
- Mature - used on Todoist.com since 2007
- Unified things that work in all the modern browsers (IE 7+)
- Functional programming
- DOM helpers
- Array helpers
- Element store
- Powerful and easy to use requests
- Deferred abstraction
- Class abstraction
- Effects
- Drag and drop helpers
- and a lot more...
ICE示例:
// Requests function loadUsers() { var req = $requestJSON('/users/get') req.addCallback(function(users) { var user_holder = $('user_holder') $map(users, function(user) { var li = LI({c: 'user'}, user.name) $AEV(li, 'click', UserController.click) $add(user_holder, li) }) }) req.sendReq({token: TOKEN}) } // Events $AEV(window, 'load', loadUsers) // Effects $fx.setWidth($('fluffy_4'), {from: 150, to: 400}) // Array helpers $arrayFlatten([[1, 2, [3, 4]], 5]) == [1, 2, 3, 4, 5] // DOM abstraction $add($body(), DIV({c: 'my_class', s:'padding-top: 10px'}, "Hello")) // Element store ElementStore.set(elm, "meaning of life", {42: 42})