Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

component-as-module

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

component-as-module - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

6

History.md
0.0.3 / 2013-04-17
==================
* Should lookup dependency by short name only in a child `node_modules` dir.
(Reverts previous release)
0.0.2 / 2013-04-17

@@ -3,0 +9,0 @@ ==================

11

lib/loader.js

@@ -195,7 +195,8 @@ var fs = require('fs')

var path = this.lookup(name)
var path = this._lookup.find(name)
if (!path && shortName && shortName != name) {
// failed to lookup by fullname (like repo-foo)
// let's try by partial name (foo)
path = this.lookup(shortName)
// but only in a node_modules dir
path = this._lookup.findIn(this.path('node_modules'), shortName)
}

@@ -205,3 +206,3 @@

? new Loader(path, this).implicitPaths()
: this.parent && this.parent.loadComponent(name, shortName)
: this.parent && this.parent.loadComponent(name)

@@ -219,6 +220,2 @@ if (!comp) throw new Error('Failed to lookup component ' + name)

Loader.prototype.lookup = function(name) {
return this._lookup.find(name)
}
function mix(t) {

@@ -225,0 +222,0 @@ var sources = [].slice.call(arguments, 1)

@@ -17,17 +17,13 @@ var join = require('path').join

Lookup.prototype.find = function(item) {
return this.eachPath(function(path, items) {
if (!~items.indexOf(item)) return
return join(path, item)
})
}
Lookup.prototype.eachPath = function(cb) {
for (var i = 0; i < this.paths.length; i++) {
var path = this.paths[i]
var items = this.cache[path] || (this.cache[path] = readdir(path))
var result = cb(path, items)
if (result) return result
var path = this.findIn(this.paths[i], item)
if (path) return path
}
}
Lookup.prototype.findIn = function(dir, item) {
var items = this.cache[dir] || (this.cache[dir] = readdir(dir))
if (~items.indexOf(item)) return join(dir, item)
}
function readdir(dir) {

@@ -34,0 +30,0 @@ try {

{
"name": "component-as-module",
"version": "0.0.2",
"version": "0.0.3",
"author": "Eldar Gabdullin <eldargab@gmail.com>",

@@ -5,0 +5,0 @@ "description": "Require components from node programs as well as share them with npm community.",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc