favicon-component
Advanced tools
+111
-87
@@ -0,1 +1,2 @@ | ||
| /** | ||
@@ -9,23 +10,28 @@ * Require the given path. | ||
| function require(p, parent, orig){ | ||
| var path = require.resolve(p) | ||
| , mod = require.modules[path]; | ||
| function require(path, parent, orig) { | ||
| var resolved = require.resolve(path); | ||
| // lookup failed | ||
| if (null == path) { | ||
| orig = orig || p; | ||
| if (null == resolved) { | ||
| orig = orig || path; | ||
| parent = parent || 'root'; | ||
| throw new Error('failed to require "' + orig + '" from "' + parent + '"'); | ||
| var err = new Error('Failed to require "' + orig + '" from "' + parent + '"'); | ||
| err.path = orig; | ||
| err.parent = parent; | ||
| err.require = true; | ||
| throw err; | ||
| } | ||
| var module = require.modules[resolved]; | ||
| // perform real require() | ||
| // by invoking the module's | ||
| // registered function | ||
| if (!mod.exports) { | ||
| mod.exports = {}; | ||
| mod.client = mod.component = true; | ||
| mod.call(mod.exports, mod, mod.exports, require.relative(path)); | ||
| if (!module.exports) { | ||
| module.exports = {}; | ||
| module.client = module.component = true; | ||
| module.call(this, module.exports, require.relative(resolved), module); | ||
| } | ||
| return mod.exports; | ||
| return module.exports; | ||
| } | ||
@@ -59,15 +65,22 @@ | ||
| require.resolve = function(path){ | ||
| var orig = path | ||
| , reg = path + '.js' | ||
| , regJSON = path + '.json' | ||
| , index = path + '/index.js' | ||
| , indexJSON = path + '/index.json'; | ||
| require.resolve = function(path) { | ||
| if (path.charAt(0) === '/') path = path.slice(1); | ||
| var index = path + '/index.js'; | ||
| return require.modules[reg] && reg | ||
| || require.modules[regJSON] && regJSON | ||
| || require.modules[index] && index | ||
| || require.modules[indexJSON] && indexJSON | ||
| || require.modules[orig] && orig | ||
| || null; | ||
| var paths = [ | ||
| path, | ||
| path + '.js', | ||
| path + '.json', | ||
| path + '/index.js', | ||
| path + '/index.json' | ||
| ]; | ||
| for (var i = 0; i < paths.length; i++) { | ||
| var path = paths[i]; | ||
| if (require.modules.hasOwnProperty(path)) return path; | ||
| } | ||
| if (require.aliases.hasOwnProperty(index)) { | ||
| return require.aliases[index]; | ||
| } | ||
| }; | ||
@@ -87,4 +100,3 @@ | ||
| // foo | ||
| if ('.' != path[0]) return path; | ||
| if ('.' != path.charAt(0)) return path; | ||
@@ -106,11 +118,11 @@ curr = curr.split('/'); | ||
| /** | ||
| * Register module at `path` with callback `fn`. | ||
| * Register module at `path` with callback `definition`. | ||
| * | ||
| * @param {String} path | ||
| * @param {Function} fn | ||
| * @param {Function} definition | ||
| * @api private | ||
| */ | ||
| require.register = function(path, fn){ | ||
| require.modules[path] = fn; | ||
| require.register = function(path, definition) { | ||
| require.modules[path] = definition; | ||
| }; | ||
@@ -126,5 +138,6 @@ | ||
| require.alias = function(from, to){ | ||
| var fn = require.modules[from]; | ||
| if (!fn) throw new Error('failed to alias "' + from + '", it does not exist'); | ||
| require.alias = function(from, to) { | ||
| if (!require.modules.hasOwnProperty(from)) { | ||
| throw new Error('Failed to alias "' + from + '", it does not exist'); | ||
| } | ||
| require.aliases[to] = from; | ||
@@ -145,11 +158,20 @@ }; | ||
| /** | ||
| * lastIndexOf helper. | ||
| */ | ||
| function lastIndexOf(arr, obj) { | ||
| var i = arr.length; | ||
| while (i--) { | ||
| if (arr[i] === obj) return i; | ||
| } | ||
| return -1; | ||
| } | ||
| /** | ||
| * The relative require() itself. | ||
| */ | ||
| function fn(path){ | ||
| var orig = path; | ||
| path = fn.resolve(path); | ||
| var alias = require.aliases[path + '/index.js']; | ||
| if (alias) path = alias; | ||
| return require(path, parent, orig); | ||
| function localRequire(path) { | ||
| var resolved = localRequire.resolve(path); | ||
| return require(resolved, parent, path); | ||
| } | ||
@@ -161,14 +183,15 @@ | ||
| fn.resolve = function(path){ | ||
| localRequire.resolve = function(path) { | ||
| var c = path.charAt(0); | ||
| if ('/' == c) return path.slice(1); | ||
| if ('.' == c) return require.normalize(p, path); | ||
| // resolve deps by returning | ||
| // the dep in the nearest "deps" | ||
| // directory | ||
| if ('.' != path[0]) { | ||
| var segs = parent.split('/'); | ||
| var i = segs.lastIndexOf('deps') + 1; | ||
| if (!i) i = 0; | ||
| path = segs.slice(0, i + 1).join('/') + '/deps/' + path; | ||
| return path; | ||
| } | ||
| return require.normalize(p, path); | ||
| var segs = parent.split('/'); | ||
| var i = lastIndexOf(segs, 'deps') + 1; | ||
| if (!i) i = 0; | ||
| path = segs.slice(0, i + 1).join('/') + '/deps/' + path; | ||
| return path; | ||
| }; | ||
@@ -180,8 +203,9 @@ | ||
| fn.exists = function(path){ | ||
| return !! require.modules[fn.resolve(path)]; | ||
| localRequire.exists = function(path) { | ||
| return require.modules.hasOwnProperty(localRequire.resolve(path)); | ||
| }; | ||
| return fn; | ||
| };require.register("favicon/index.js", function(module, exports, require){ | ||
| return localRequire; | ||
| }; | ||
| require.register("favicon/index.js", function(exports, require, module){ | ||
@@ -207,8 +231,2 @@ /** | ||
| /** | ||
| * Expose `current()`. | ||
| */ | ||
| exports.current = current; | ||
| /** | ||
| * Set the favicon to the given data uri `str`. | ||
@@ -222,24 +240,29 @@ * | ||
| if ('string' != typeof str) throw new TypeError('data uri string expected'); | ||
| var prev = remove(); | ||
| if (!orig) orig = prev; | ||
| var link = document.createElement('link'); | ||
| link.type = 'image/x-icon'; | ||
| link.rel = 'icon'; | ||
| link.href = str; | ||
| head().appendChild(link); | ||
| // orig | ||
| var el = link(); | ||
| if (el && !orig) orig = el.href; | ||
| // create | ||
| if (!el) { | ||
| el = create(); | ||
| head().appendChild(el); | ||
| } | ||
| el.href = str; | ||
| } | ||
| /** | ||
| * Reset to the original favicon. | ||
| * Return the favicon link. | ||
| * | ||
| * @api public | ||
| * @return {Element} | ||
| * @api private | ||
| */ | ||
| function reset() { | ||
| remove(); | ||
| if (orig) head().appendChild(orig); | ||
| function link() { | ||
| return document.querySelector('link[rel=icon]'); | ||
| } | ||
| /** | ||
| * Return current favicon link with rel=icon. | ||
| * Create a new link. | ||
| * | ||
@@ -250,25 +273,24 @@ * @return {Element} | ||
| function current() { | ||
| var rel; | ||
| var links = document.getElementsByTagName('link'); | ||
| for (var i = 0; i < links.length; ++i) { | ||
| rel = links[i].getAttribute('rel') || ''; | ||
| if (rel.match(/\bicon\b/)) { | ||
| return links[i]; | ||
| } | ||
| } | ||
| function create() { | ||
| var el = document.createElement('link'); | ||
| el.type = 'image/x-icon'; | ||
| el.rel = 'icon'; | ||
| return el; | ||
| } | ||
| /** | ||
| * Remove current favicon link with rel=icon. | ||
| * Reset to the original favicon. | ||
| * | ||
| * @return {Element} | ||
| * @api private | ||
| * @api public | ||
| */ | ||
| function remove() { | ||
| var link = current(); | ||
| if (!link) return; | ||
| head().removeChild(link); | ||
| return link; | ||
| function reset() { | ||
| var el = document.querySelector('link[rel=icon]'); | ||
| if (!orig) { | ||
| head().removeChild(el); | ||
| return; | ||
| } | ||
| el.href = orig; | ||
| } | ||
@@ -286,2 +308,4 @@ | ||
| } | ||
| }); | ||
+1
-1
| { | ||
| "name": "favicon", | ||
| "description": "Dynamic favicon replacement component", | ||
| "version": "0.0.5", | ||
| "version": "1.0.0", | ||
| "keywords": ["favicon", "image", "ui", "canvas"], | ||
@@ -6,0 +6,0 @@ "dependencies": {}, |
+5
-0
| 1.0.0 / 2013-04-16 | ||
| ================== | ||
| * rewrite | ||
| 0.0.5 / 2012-09-20 | ||
@@ -3,0 +8,0 @@ ================== |
+35
-37
@@ -21,8 +21,2 @@ | ||
| /** | ||
| * Expose `current()`. | ||
| */ | ||
| exports.current = current; | ||
| /** | ||
| * Set the favicon to the given data uri `str`. | ||
@@ -36,24 +30,29 @@ * | ||
| if ('string' != typeof str) throw new TypeError('data uri string expected'); | ||
| var prev = remove(); | ||
| if (!orig) orig = prev; | ||
| var link = document.createElement('link'); | ||
| link.type = 'image/x-icon'; | ||
| link.rel = 'icon'; | ||
| link.href = str; | ||
| head().appendChild(link); | ||
| // orig | ||
| var el = link(); | ||
| if (el && !orig) orig = el.href; | ||
| // create | ||
| if (!el) { | ||
| el = create(); | ||
| head().appendChild(el); | ||
| } | ||
| el.href = str; | ||
| } | ||
| /** | ||
| * Reset to the original favicon. | ||
| * Return the favicon link. | ||
| * | ||
| * @api public | ||
| * @return {Element} | ||
| * @api private | ||
| */ | ||
| function reset() { | ||
| remove(); | ||
| if (orig) head().appendChild(orig); | ||
| function link() { | ||
| return document.querySelector('link[rel=icon]'); | ||
| } | ||
| /** | ||
| * Return current favicon link with rel=icon. | ||
| * Create a new link. | ||
| * | ||
@@ -64,25 +63,24 @@ * @return {Element} | ||
| function current() { | ||
| var rel; | ||
| var links = document.getElementsByTagName('link'); | ||
| for (var i = 0; i < links.length; ++i) { | ||
| rel = links[i].getAttribute('rel') || ''; | ||
| if (rel.match(/\bicon\b/)) { | ||
| return links[i]; | ||
| } | ||
| } | ||
| function create() { | ||
| var el = document.createElement('link'); | ||
| el.type = 'image/x-icon'; | ||
| el.rel = 'icon'; | ||
| return el; | ||
| } | ||
| /** | ||
| * Remove current favicon link with rel=icon. | ||
| * Reset to the original favicon. | ||
| * | ||
| * @return {Element} | ||
| * @api private | ||
| * @api public | ||
| */ | ||
| function remove() { | ||
| var link = current(); | ||
| if (!link) return; | ||
| head().removeChild(link); | ||
| return link; | ||
| function reset() { | ||
| var el = document.querySelector('link[rel=icon]'); | ||
| if (!orig) { | ||
| head().removeChild(el); | ||
| return; | ||
| } | ||
| el.href = orig; | ||
| } | ||
@@ -99,2 +97,2 @@ | ||
| return document.getElementsByTagName('head')[0]; | ||
| } | ||
| } |
+1
-1
| { | ||
| "name": "favicon-component", | ||
| "description": "Dynamic favicon replacement component", | ||
| "version": "0.0.5", | ||
| "version": "1.0.0", | ||
| "keywords": ["favicon", "image", "ui", "canvas"], | ||
@@ -6,0 +6,0 @@ "dependencies": {}, |
+1
-5
@@ -45,8 +45,4 @@ | ||
| ### icon.current() | ||
| Return the current favicon link when present. | ||
| ## License | ||
| MIT | ||
| MIT |
| { | ||
| "name": "emitter", | ||
| "description": "Event emitter", | ||
| "keywords": [ | ||
| "emitter", | ||
| "events" | ||
| ], | ||
| "version": "0.0.3", | ||
| "scripts": [ | ||
| "index.js" | ||
| ], | ||
| "repo": "https://github.com/component/emitter" | ||
| } |
| /** | ||
| * Expose `Emitter`. | ||
| */ | ||
| module.exports = Emitter; | ||
| /** | ||
| * Initialize a new `Emitter`. | ||
| * | ||
| * @api public | ||
| */ | ||
| function Emitter() { | ||
| this.callbacks = {}; | ||
| }; | ||
| /** | ||
| * Listen on the given `event` with `fn`. | ||
| * | ||
| * @param {String} event | ||
| * @param {Function} fn | ||
| * @return {Emitter} | ||
| * @api public | ||
| */ | ||
| Emitter.prototype.on = function(event, fn){ | ||
| (this.callbacks[event] = this.callbacks[event] || []) | ||
| .push(fn); | ||
| return this; | ||
| }; | ||
| /** | ||
| * Adds an `event` listener that will be invoked a single | ||
| * time then automatically removed. | ||
| * | ||
| * @param {String} event | ||
| * @param {Function} fn | ||
| * @return {Emitter} | ||
| * @api public | ||
| */ | ||
| Emitter.prototype.once = function(event, fn){ | ||
| var self = this; | ||
| function on() { | ||
| self.off(event, on); | ||
| fn.apply(this, arguments); | ||
| } | ||
| fn._off = on; | ||
| this.on(event, on); | ||
| return this; | ||
| }; | ||
| /** | ||
| * Remove the given callback for `event` or all | ||
| * registered callbacks. | ||
| * | ||
| * @param {String} event | ||
| * @param {Function} fn | ||
| * @return {Emitter} | ||
| * @api public | ||
| */ | ||
| Emitter.prototype.off = function(event, fn){ | ||
| var callbacks = this.callbacks[event]; | ||
| if (!callbacks) return this; | ||
| // remove all handlers | ||
| if (1 == arguments.length) { | ||
| delete this.callbacks[event]; | ||
| return this; | ||
| } | ||
| // remove specific handler | ||
| var i = callbacks.indexOf(fn._off || fn); | ||
| if (~i) callbacks.splice(i, 1); | ||
| return this; | ||
| }; | ||
| /** | ||
| * Emit `event` with the given args. | ||
| * | ||
| * @param {String} event | ||
| * @param {Mixed} ... | ||
| * @return {Emitter} | ||
| */ | ||
| Emitter.prototype.emit = function(event){ | ||
| var args = [].slice.call(arguments, 1) | ||
| , callbacks = this.callbacks[event]; | ||
| if (callbacks) { | ||
| callbacks = callbacks.slice(0); | ||
| for (var i = 0, len = callbacks.length; i < len; ++i) { | ||
| callbacks[i].apply(this, args); | ||
| } | ||
| } | ||
| return this; | ||
| }; | ||
| /** | ||
| * Return array of callbacks for `event`. | ||
| * | ||
| * @param {String} event | ||
| * @return {Array} | ||
| * @api public | ||
| */ | ||
| Emitter.prototype.listeners = function(event){ | ||
| return this.callbacks[event] || []; | ||
| }; | ||
| /** | ||
| * Check if this emitter has `event` handlers. | ||
| * | ||
| * @param {String} event | ||
| * @return {Boolean} | ||
| * @api public | ||
| */ | ||
| Emitter.prototype.hasListeners = function(event){ | ||
| return !! this.listeners(event).length; | ||
| }; | ||
| { | ||
| "name": "jquery", | ||
| "version": "1.7.3pre", | ||
| "description": "jQuery component", | ||
| "keywords": [ | ||
| "jquery", | ||
| "component" | ||
| ], | ||
| "scripts": [ | ||
| "index.js" | ||
| ], | ||
| "repo": "https://github.com/component/jquery" | ||
| } |
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1
-50%5
-90.74%1
-66.67%7845
-97.02%8
-38.46%320
-96.1%48
-5.88%