-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
49 lines (37 loc) · 860 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var _ = require('min-util')
var parse = require('min-parse')
var find = require('min-find')
var uid = require('muid')
uid.prefix = 'minJQ-'
var doc = global.document
var is = _.is
module.exports = exports = $
function $(val, box) {
if (is.fn(val)) return $(doc).ready(val)
if (!(this instanceof $)) return new $(val, box)
this.length = 0
if (!val) return
if (is.string(val)) {
if (-1 == val.indexOf('<')) {
val = find(val, box)
} else {
val = parse.html(val)
}
}
if (!is.arraylike(val)) val = [val]
var len = val.length
for (var i = 0; i < len; i++) {
this[i] = val[i]
}
this.length = len
}
var proto = $.fn = $.prototype
$.extend = proto.extend = function() {
var arr = arguments
if (1 == arr.length) {
return _.extend(this, arr[0])
}
return _.extend.apply(_, arr)
}
proto.extend({jquery: true})
require('./extend')