file-component
Advanced tools
| { | ||
| "name": "indexof", | ||
| "description": "Microsoft sucks", | ||
| "version": "0.0.1", | ||
| "keywords": [ | ||
| "index", | ||
| "array", | ||
| "indexOf" | ||
| ], | ||
| "dependencies": {}, | ||
| "scripts": [ | ||
| "index.js" | ||
| ], | ||
| "repo": "https://raw.github.com/component/indexof" | ||
| } |
| var indexOf = [].indexOf; | ||
| module.exports = function(arr, obj){ | ||
| if (indexOf) return arr.indexOf(obj); | ||
| for (var i = 0; i < arr.length; ++i) { | ||
| if (arr[i] === obj) return i; | ||
| } | ||
| return -1; | ||
| }; |
+207
-69
@@ -10,12 +10,28 @@ | ||
| function require(p, parent){ | ||
| var path = require.resolve(p) | ||
| , mod = require.modules[path]; | ||
| if (!mod) throw new Error('failed to require "' + p + '" in ' + (parent || 'root')); | ||
| if (!mod.exports) { | ||
| mod.exports = {}; | ||
| mod.client = true; | ||
| mod.call(mod.exports, mod, mod.exports, require.relative(path)); | ||
| function require(path, parent, orig) { | ||
| var resolved = require.resolve(path); | ||
| // lookup failed | ||
| if (null == resolved) { | ||
| orig = orig || path; | ||
| parent = parent || 'root'; | ||
| var err = new Error('Failed to require "' + orig + '" from "' + parent + '"'); | ||
| err.path = orig; | ||
| err.parent = parent; | ||
| err.require = true; | ||
| throw err; | ||
| } | ||
| return mod.exports; | ||
| var module = require.modules[resolved]; | ||
| // perform real require() | ||
| // by invoking the module's | ||
| // registered function | ||
| if (!module.exports) { | ||
| module.exports = {}; | ||
| module.client = module.component = true; | ||
| module.call(this, module.exports, require.relative(resolved), module); | ||
| } | ||
| return module.exports; | ||
| } | ||
@@ -30,56 +46,96 @@ | ||
| /** | ||
| * Check if a module defined at `path` exists. | ||
| * Registered aliases. | ||
| */ | ||
| require.aliases = {}; | ||
| /** | ||
| * Resolve `path`. | ||
| * | ||
| * Lookup: | ||
| * | ||
| * - PATH/index.js | ||
| * - PATH.js | ||
| * - PATH | ||
| * | ||
| * @param {String} path | ||
| * @return {Boolean} | ||
| * @api public | ||
| * @return {String} path or null | ||
| * @api private | ||
| */ | ||
| require.exists = function(path){ | ||
| return !! require.modules[require.resolve(path)]; | ||
| require.resolve = function(path) { | ||
| if (path.charAt(0) === '/') path = path.slice(1); | ||
| var index = path + '/index.js'; | ||
| 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]; | ||
| } | ||
| }; | ||
| /** | ||
| * Resolve `path`. | ||
| * Normalize `path` relative to the current path. | ||
| * | ||
| * @param {String} curr | ||
| * @param {String} path | ||
| * @return {Object} module | ||
| * @api public | ||
| * @return {String} | ||
| * @api private | ||
| */ | ||
| require.resolve = function(path){ | ||
| var orig = path | ||
| , reg = path + '.js' | ||
| , base = path + '/' + path + '.js' | ||
| , index = path + '/index.js'; | ||
| require.normalize = function(curr, path) { | ||
| var segs = []; | ||
| return require.modules[reg] && reg | ||
| || require.modules[index] && index | ||
| || require.modules[base] && base | ||
| || orig; | ||
| if ('.' != path.charAt(0)) return path; | ||
| curr = curr.split('/'); | ||
| path = path.split('/'); | ||
| for (var i = 0; i < path.length; ++i) { | ||
| if ('..' == path[i]) { | ||
| curr.pop(); | ||
| } else if ('.' != path[i] && '' != path[i]) { | ||
| segs.push(path[i]); | ||
| } | ||
| } | ||
| return curr.concat(segs).join('/'); | ||
| }; | ||
| /** | ||
| * Register module at `path` with callback `fn`. | ||
| * Register module at `path` with callback `definition`. | ||
| * | ||
| * @param {String} path | ||
| * @param {Function} fn | ||
| * @api public | ||
| * @param {Function} definition | ||
| * @api private | ||
| */ | ||
| require.register = function(path, fn){ | ||
| require.modules[path] = fn; | ||
| require.register = function(path, definition) { | ||
| require.modules[path] = definition; | ||
| }; | ||
| /** | ||
| * Defines and executes anonymous module immediately, while preserving relative | ||
| * paths. | ||
| * Alias a module definition. | ||
| * | ||
| * @param {String} path | ||
| * @param {Function} require ref | ||
| * @api public | ||
| * @param {String} from | ||
| * @param {String} to | ||
| * @api private | ||
| */ | ||
| require.exec = function (path, fn) { | ||
| fn.call(window, require.relative(path)); | ||
| 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; | ||
| }; | ||
@@ -96,25 +152,75 @@ | ||
| require.relative = function(parent) { | ||
| function fn(p){ | ||
| if ('.' != p[0]) return require(p, parent); | ||
| var path = parent.split('/'); | ||
| var segs = p.split('/'); | ||
| path.pop(); | ||
| for (var i = 0; i < segs.length; i++) { | ||
| var seg = segs[i]; | ||
| if ('..' == seg) path.pop(); | ||
| else if ('.' != seg) path.push(seg); | ||
| var p = require.normalize(parent, '..'); | ||
| /** | ||
| * lastIndexOf helper. | ||
| */ | ||
| function lastIndexOf(arr, obj) { | ||
| var i = arr.length; | ||
| while (i--) { | ||
| if (arr[i] === obj) return i; | ||
| } | ||
| return -1; | ||
| } | ||
| return require(path.join('/'), parent); | ||
| /** | ||
| * The relative require() itself. | ||
| */ | ||
| function localRequire(path) { | ||
| var resolved = localRequire.resolve(path); | ||
| return require(resolved, parent, path); | ||
| } | ||
| fn.exists = require.exists; | ||
| /** | ||
| * Resolve relative to the parent. | ||
| */ | ||
| return fn; | ||
| 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 | ||
| 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; | ||
| }; | ||
| /** | ||
| * Check if module is defined at `path`. | ||
| */ | ||
| localRequire.exists = function(path) { | ||
| return require.modules.hasOwnProperty(localRequire.resolve(path)); | ||
| }; | ||
| return localRequire; | ||
| }; | ||
| require.register("emitter/index.js", function(module, exports, require){ | ||
| require.register("component-indexof/index.js", function(exports, require, module){ | ||
| var indexOf = [].indexOf; | ||
| module.exports = function(arr, obj){ | ||
| if (indexOf) return arr.indexOf(obj); | ||
| for (var i = 0; i < arr.length; ++i) { | ||
| if (arr[i] === obj) return i; | ||
| } | ||
| return -1; | ||
| }; | ||
| }); | ||
| require.register("component-emitter/index.js", function(exports, require, module){ | ||
| /** | ||
| * Module dependencies. | ||
| */ | ||
| var index = require('indexof'); | ||
| /** | ||
| * Expose `Emitter`. | ||
@@ -127,11 +233,26 @@ */ | ||
| * Initialize a new `Emitter`. | ||
| * | ||
| * | ||
| * @api public | ||
| */ | ||
| function Emitter() { | ||
| this.callbacks = {}; | ||
| function Emitter(obj) { | ||
| if (obj) return mixin(obj); | ||
| }; | ||
| /** | ||
| * Mixin the emitter properties. | ||
| * | ||
| * @param {Object} obj | ||
| * @return {Object} | ||
| * @api private | ||
| */ | ||
| function mixin(obj) { | ||
| for (var key in Emitter.prototype) { | ||
| obj[key] = Emitter.prototype[key]; | ||
| } | ||
| return obj; | ||
| } | ||
| /** | ||
| * Listen on the given `event` with `fn`. | ||
@@ -146,3 +267,4 @@ * | ||
| Emitter.prototype.on = function(event, fn){ | ||
| (this.callbacks[event] = this.callbacks[event] || []) | ||
| this._callbacks = this._callbacks || {}; | ||
| (this._callbacks[event] = this._callbacks[event] || []) | ||
| .push(fn); | ||
@@ -164,2 +286,3 @@ return this; | ||
| var self = this; | ||
| this._callbacks = this._callbacks || {}; | ||
@@ -186,4 +309,15 @@ function on() { | ||
| Emitter.prototype.off = function(event, fn){ | ||
| var callbacks = this.callbacks[event]; | ||
| Emitter.prototype.off = | ||
| Emitter.prototype.removeListener = | ||
| Emitter.prototype.removeAllListeners = function(event, fn){ | ||
| this._callbacks = this._callbacks || {}; | ||
| // all | ||
| if (0 == arguments.length) { | ||
| this._callbacks = {}; | ||
| return this; | ||
| } | ||
| // specific event | ||
| var callbacks = this._callbacks[event]; | ||
| if (!callbacks) return this; | ||
@@ -193,3 +327,3 @@ | ||
| if (1 == arguments.length) { | ||
| delete this.callbacks[event]; | ||
| delete this._callbacks[event]; | ||
| return this; | ||
@@ -199,3 +333,3 @@ } | ||
| // remove specific handler | ||
| var i = callbacks.indexOf(fn._off || fn); | ||
| var i = index(callbacks, fn._off || fn); | ||
| if (~i) callbacks.splice(i, 1); | ||
@@ -210,8 +344,9 @@ return this; | ||
| * @param {Mixed} ... | ||
| * @return {Emitter} | ||
| * @return {Emitter} | ||
| */ | ||
| Emitter.prototype.emit = function(event){ | ||
| this._callbacks = this._callbacks || {}; | ||
| var args = [].slice.call(arguments, 1) | ||
| , callbacks = this.callbacks[event]; | ||
| , callbacks = this._callbacks[event]; | ||
@@ -237,3 +372,4 @@ if (callbacks) { | ||
| Emitter.prototype.listeners = function(event){ | ||
| return this.callbacks[event] || []; | ||
| this._callbacks = this._callbacks || {}; | ||
| return this._callbacks[event] || []; | ||
| }; | ||
@@ -253,5 +389,4 @@ | ||
| }); | ||
| require.register("file/index.js", function(module, exports, require){ | ||
| require.register("file/index.js", function(exports, require, module){ | ||
@@ -277,3 +412,3 @@ /** | ||
| }); | ||
| require.register("file/file.js", function(module, exports, require){ | ||
| require.register("file/file.js", function(exports, require, module){ | ||
@@ -410,3 +545,3 @@ /** | ||
| }); | ||
| require.register("file/reader.js", function(module, exports, require){ | ||
| require.register("file/reader.js", function(exports, require, module){ | ||
@@ -514,2 +649,5 @@ /** | ||
| }); | ||
| }); | ||
| require.alias("component-emitter/index.js", "file/deps/emitter/index.js"); | ||
| require.alias("component-indexof/index.js", "component-emitter/deps/indexof/index.js"); | ||
+1
-1
| { | ||
| "name": "file", | ||
| "description": "File & FileReader wrappers", | ||
| "version": "0.0.1", | ||
| "version": "0.0.2", | ||
| "keywords": ["file", "utility"], | ||
@@ -6,0 +6,0 @@ "dependencies": { |
@@ -8,7 +8,11 @@ { | ||
| ], | ||
| "version": "0.0.3", | ||
| "dependencies": { | ||
| "component/indexof": "*" | ||
| }, | ||
| "version": "1.0.0", | ||
| "scripts": [ | ||
| "index.js" | ||
| ], | ||
| "repo": "https://github.com/component/emitter" | ||
| "license": "MIT", | ||
| "repo": "https://raw.github.com/component/emitter" | ||
| } |
| /** | ||
| * Module dependencies. | ||
| */ | ||
| var index = require('indexof'); | ||
| /** | ||
| * Expose `Emitter`. | ||
@@ -10,11 +16,26 @@ */ | ||
| * Initialize a new `Emitter`. | ||
| * | ||
| * | ||
| * @api public | ||
| */ | ||
| function Emitter() { | ||
| this.callbacks = {}; | ||
| function Emitter(obj) { | ||
| if (obj) return mixin(obj); | ||
| }; | ||
| /** | ||
| * Mixin the emitter properties. | ||
| * | ||
| * @param {Object} obj | ||
| * @return {Object} | ||
| * @api private | ||
| */ | ||
| function mixin(obj) { | ||
| for (var key in Emitter.prototype) { | ||
| obj[key] = Emitter.prototype[key]; | ||
| } | ||
| return obj; | ||
| } | ||
| /** | ||
| * Listen on the given `event` with `fn`. | ||
@@ -29,3 +50,4 @@ * | ||
| Emitter.prototype.on = function(event, fn){ | ||
| (this.callbacks[event] = this.callbacks[event] || []) | ||
| this._callbacks = this._callbacks || {}; | ||
| (this._callbacks[event] = this._callbacks[event] || []) | ||
| .push(fn); | ||
@@ -47,2 +69,3 @@ return this; | ||
| var self = this; | ||
| this._callbacks = this._callbacks || {}; | ||
@@ -69,4 +92,15 @@ function on() { | ||
| Emitter.prototype.off = function(event, fn){ | ||
| var callbacks = this.callbacks[event]; | ||
| Emitter.prototype.off = | ||
| Emitter.prototype.removeListener = | ||
| Emitter.prototype.removeAllListeners = function(event, fn){ | ||
| this._callbacks = this._callbacks || {}; | ||
| // all | ||
| if (0 == arguments.length) { | ||
| this._callbacks = {}; | ||
| return this; | ||
| } | ||
| // specific event | ||
| var callbacks = this._callbacks[event]; | ||
| if (!callbacks) return this; | ||
@@ -76,3 +110,3 @@ | ||
| if (1 == arguments.length) { | ||
| delete this.callbacks[event]; | ||
| delete this._callbacks[event]; | ||
| return this; | ||
@@ -82,3 +116,3 @@ } | ||
| // remove specific handler | ||
| var i = callbacks.indexOf(fn._off || fn); | ||
| var i = index(callbacks, fn._off || fn); | ||
| if (~i) callbacks.splice(i, 1); | ||
@@ -93,8 +127,9 @@ return this; | ||
| * @param {Mixed} ... | ||
| * @return {Emitter} | ||
| * @return {Emitter} | ||
| */ | ||
| Emitter.prototype.emit = function(event){ | ||
| this._callbacks = this._callbacks || {}; | ||
| var args = [].slice.call(arguments, 1) | ||
| , callbacks = this.callbacks[event]; | ||
| , callbacks = this._callbacks[event]; | ||
@@ -120,3 +155,4 @@ if (callbacks) { | ||
| Emitter.prototype.listeners = function(event){ | ||
| return this.callbacks[event] || []; | ||
| this._callbacks = this._callbacks || {}; | ||
| return this._callbacks[event] || []; | ||
| }; | ||
@@ -135,2 +171,1 @@ | ||
| }; | ||
+1
-0
@@ -87,2 +87,3 @@ | ||
| File.prototype.to = function(type, fn){ | ||
| if (!window.FileReader) return fn(); | ||
| var reader = Reader(); | ||
@@ -89,0 +90,0 @@ reader.on('error', fn); |
+1
-1
| { | ||
| "name": "file-component", | ||
| "description": "File & FileReader wrappers", | ||
| "version": "0.0.1", | ||
| "version": "0.0.2", | ||
| "keywords": ["file", "utility"], | ||
@@ -6,0 +6,0 @@ "dependencies": { |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
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
21183
24.97%14
7.69%901
23.26%0
-100%6
50%1
Infinity%