Skip to content

Commit d51ea84

Browse files
committed
m
1 parent f6b6298 commit d51ea84

File tree

5 files changed

+94
-88
lines changed

5 files changed

+94
-88
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ branches:
44
- gh-pages
55
env:
66
global:
7-
- SAUCE_USERNAME: ftft1885
8-
- secure: KC1UlwOFFUFvZdlpGIfDRgxCzmOu6/x5e1bqafv8poNZlYSPAy8kI5Og1kBw3HPzVwcNYdgGaYcNaXNpVtL7mB+ydverNyJpbfaPRORDPTdRzDinC2g0Skjqykcoy8KyfcxAG1zVlrifFA8tabHFrIV61RUel4RyKQwNXt8xK3o=
7+
- SAUCE_USERNAME: chunpu2
8+
- secure: OMVf/+rpzndbubW3TBwHNLosdObLV/YYE9OSh3TyRmDfD6jAo9sSoR1CZkd+foeX1rkFr614mAzk9+ubKI2gDjpGQGgkGFu030urxZA5LKbZnqd0+xGqyubcH5I9rstAPotu2O2XYpBfDfEqGj81pIwqop790GJm7TZLMqiwFwo=

browser.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
module.exports = exports = require('./')
2-
exports.init()

debug.js

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,20 @@
1-
module.exports = exports = debug
2-
3-
exports.names = []
4-
exports.skips = []
1+
module.exports = exports = Debug
52

63
var colors = 'lightseagreen forestgreen goldenrod dodgerblue darkorchid crimson'.split(' ')
74
var colorIndex = 0
8-
9-
exports.prefix = ''
10-
11-
function noop() {}
12-
13-
function enable(namespaces) {
14-
if (!namespaces) return
15-
var split = namespaces.split(/[\s,]+/)
16-
for (var i = 0; i < split.length; i++) {
17-
if (!split[i]) continue
18-
namespaces = split[i].replace(/\*/g, '.*?')
19-
if ('-' == namespaces[0])
20-
exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'))
21-
else
22-
exports.names.push(new RegExp('^' + namespaces + '$'))
23-
}
24-
}
25-
26-
function enabled(name) {
27-
var i = 0, reg
28-
for (i = 0; reg = exports.skips[i++];) {
29-
if (reg.test(name)) return false
30-
}
31-
for (i = 0; reg = exports.names[i++];) {
32-
if (reg.test(name)) return true
33-
}
34-
}
35-
36-
function getColor() {
37-
return colors[colorIndex++ % colors.length]
38-
}
39-
405
var prev
416
var inherit = 'color:inherit'
427
var console = global.console
8+
var doc = global.document
9+
var names = []
10+
var skips = []
11+
12+
init()
13+
14+
exports.prefix = ''
4315

4416
exports.log = function(namespace, args, color) {
45-
var curr = +new Date()
17+
var curr = +new Date
4618
var ms = curr - (prev || curr)
4719
prev = curr
4820

@@ -59,20 +31,21 @@ exports.log = function(namespace, args, color) {
5931
console.debug.apply(console, arr)
6032
}
6133

62-
function debug(namespace) {
34+
exports.init = init
35+
36+
function Debug(namespace) {
6337
var color = 'color:' + getColor()
6438
return enabled(namespace) ? function() {
6539
exports.log(namespace, arguments, color)
6640
} : noop
6741
}
6842

69-
exports.init = function(key) {
43+
function init(key) {
7044
key = key || 'debug'
7145
var reg = new RegExp(key + '=(\\S+)')
7246
var res = reg.exec(location.href)
7347
if (res) {
7448
enable(res[1])
75-
var doc = document
7649
var elem = doc.createElement('textarea')
7750
elem.style.cssText = 'width:100%;height:300px;overflow:auto;line-height:1.4;background:#333;color:#fff;font:16px Consolas;border:none'
7851
var box = doc.body || doc.documentElement
@@ -85,7 +58,7 @@ exports.init = function(key) {
8558
try {
8659
val = JSON.stringify(val, 0, 4)
8760
} catch (e) {
88-
val = val + ''
61+
val += ''
8962
}
9063
ret.push(val)
9164
}
@@ -99,3 +72,34 @@ exports.init = function(key) {
9972
} catch (ignore) {}
10073
}
10174
}
75+
76+
function noop() {}
77+
78+
function enable(namespaces) {
79+
if (!namespaces) return
80+
skips = []
81+
names = []
82+
var split = namespaces.split(/[\s,]+/)
83+
for (var i = 0; i < split.length; i++) {
84+
if (!split[i]) continue
85+
namespaces = split[i].replace(/\*/g, '.*?')
86+
if ('-' == namespaces[0])
87+
skips.push(new RegExp('^' + namespaces.substr(1) + '$'))
88+
else
89+
names.push(new RegExp('^' + namespaces + '$'))
90+
}
91+
}
92+
93+
function enabled(name) {
94+
var i = 0, reg
95+
for (i = 0; reg = skips[i++];) {
96+
if (reg.test(name)) return false
97+
}
98+
for (i = 0; reg = names[i++];) {
99+
if (reg.test(name)) return true
100+
}
101+
}
102+
103+
function getColor() {
104+
return colors[colorIndex++ % colors.length]
105+
}

dist/debug.js

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,25 @@
1-
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.debug=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
1+
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.debug = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
22
module.exports = exports = require('./')
3-
exports.init()
43

54
},{"./":2}],2:[function(require,module,exports){
65
(function (global){
7-
module.exports = exports = debug
8-
9-
exports.names = []
10-
exports.skips = []
6+
module.exports = exports = Debug
117

128
var colors = 'lightseagreen forestgreen goldenrod dodgerblue darkorchid crimson'.split(' ')
139
var colorIndex = 0
14-
15-
exports.prefix = ''
16-
17-
function noop() {}
18-
19-
function enable(namespaces) {
20-
if (!namespaces) return
21-
var split = namespaces.split(/[\s,]+/)
22-
for (var i = 0; i < split.length; i++) {
23-
if (!split[i]) continue
24-
namespaces = split[i].replace(/\*/g, '.*?')
25-
if ('-' == namespaces[0])
26-
exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'))
27-
else
28-
exports.names.push(new RegExp('^' + namespaces + '$'))
29-
}
30-
}
31-
32-
function enabled(name) {
33-
var i = 0, reg
34-
for (i = 0; reg = exports.skips[i++];) {
35-
if (reg.test(name)) return false
36-
}
37-
for (i = 0; reg = exports.names[i++];) {
38-
if (reg.test(name)) return true
39-
}
40-
}
41-
42-
function getColor() {
43-
return colors[colorIndex++ % colors.length]
44-
}
45-
4610
var prev
4711
var inherit = 'color:inherit'
4812
var console = global.console
13+
var doc = global.document
14+
var names = []
15+
var skips = []
16+
17+
init()
18+
19+
exports.prefix = ''
4920

5021
exports.log = function(namespace, args, color) {
51-
var curr = +new Date()
22+
var curr = +new Date
5223
var ms = curr - (prev || curr)
5324
prev = curr
5425

@@ -65,20 +36,21 @@ exports.log = function(namespace, args, color) {
6536
console.debug.apply(console, arr)
6637
}
6738

68-
function debug(namespace) {
39+
exports.init = init
40+
41+
function Debug(namespace) {
6942
var color = 'color:' + getColor()
7043
return enabled(namespace) ? function() {
7144
exports.log(namespace, arguments, color)
7245
} : noop
7346
}
7447

75-
exports.init = function(key) {
48+
function init(key) {
7649
key = key || 'debug'
7750
var reg = new RegExp(key + '=(\\S+)')
7851
var res = reg.exec(location.href)
7952
if (res) {
8053
enable(res[1])
81-
var doc = document
8254
var elem = doc.createElement('textarea')
8355
elem.style.cssText = 'width:100%;height:300px;overflow:auto;line-height:1.4;background:#333;color:#fff;font:16px Consolas;border:none'
8456
var box = doc.body || doc.documentElement
@@ -91,7 +63,7 @@ exports.init = function(key) {
9163
try {
9264
val = JSON.stringify(val, 0, 4)
9365
} catch (e) {
94-
val = val + ''
66+
val += ''
9567
}
9668
ret.push(val)
9769
}
@@ -106,6 +78,37 @@ exports.init = function(key) {
10678
}
10779
}
10880

81+
function noop() {}
82+
83+
function enable(namespaces) {
84+
if (!namespaces) return
85+
skips = []
86+
names = []
87+
var split = namespaces.split(/[\s,]+/)
88+
for (var i = 0; i < split.length; i++) {
89+
if (!split[i]) continue
90+
namespaces = split[i].replace(/\*/g, '.*?')
91+
if ('-' == namespaces[0])
92+
skips.push(new RegExp('^' + namespaces.substr(1) + '$'))
93+
else
94+
names.push(new RegExp('^' + namespaces + '$'))
95+
}
96+
}
97+
98+
function enabled(name) {
99+
var i = 0, reg
100+
for (i = 0; reg = skips[i++];) {
101+
if (reg.test(name)) return false
102+
}
103+
for (i = 0; reg = names[i++];) {
104+
if (reg.test(name)) return true
105+
}
106+
}
107+
108+
function getColor() {
109+
return colors[colorIndex++ % colors.length]
110+
}
111+
109112
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
110113
},{}]},{},[1])(1)
111114
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "min-debug",
3-
"version": "1.2.6",
3+
"version": "1.3.0",
44
"description": "Debug module for browsers which can Display on page or in Console, for Phone and old IE debugging",
55
"main": "debug.js",
66
"directories": {

0 commit comments

Comments
 (0)