Skip to content

Commit 1b7de96

Browse files
committed
update
1 parent f451259 commit 1b7de96

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Binary file not shown.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
(function (root) {
2+
var _ = function () {
3+
4+
}
5+
6+
var _ = function (obj) {
7+
if (obj instanceof _) {
8+
return obj;
9+
}
10+
11+
if (!(this instanceof _)) {
12+
return new _(obj)
13+
}
14+
15+
this._wrapped = obj;
16+
}
17+
18+
_.unique = function (arr, callback) {
19+
var ret = [];
20+
var target, i = 0;
21+
for (; i < arr.length; i++) {
22+
target = callbacks ? callbacks(arr[i]) : arr[i];
23+
if (ret.indexOf(target) === -1) {
24+
ret.push(target)
25+
}
26+
}
27+
}
28+
29+
_.map = function () {
30+
31+
}
32+
33+
_.each = function (target, callback) {
34+
var key, i = 0;
35+
if (_.isArray(target)) {
36+
var length = target.length
37+
for (; i < length; i++) {
38+
callback.call(target, target[i])
39+
}
40+
} else {
41+
for (key in target) {
42+
callback.call(target, key, target[key])
43+
}
44+
}
45+
}
46+
47+
//给underscore原型上面扩展方法
48+
49+
_.mixin = function (obj) {
50+
_.each(_.function)
51+
}
52+
53+
root._ = _
54+
})(this)

0 commit comments

Comments
 (0)