Comparing version 2.2.2 to 2.2.3
18
index.js
@@ -79,5 +79,14 @@ var abbott = require('abbott'); | ||
function traceGet(instance, result){ | ||
if(righto._debug && !(typeof result === 'object' || typeof result === 'function')){ | ||
var line = getCallLine(instance._stack); | ||
throw new Error('Result of righto was not an instance at: \n' + line); | ||
} | ||
} | ||
function get(fn){ | ||
var instance = this; | ||
return righto(function(result, fn, done){ | ||
if(typeof fn === 'string'){ | ||
traceGet(instance, result); | ||
return done(null, result[fn]); | ||
@@ -99,3 +108,12 @@ } | ||
if(instance[key] || key in instance || key === 'inspect' || typeof key === 'symbol'){ | ||
return instance[key]; | ||
} | ||
if(righto._debug && key.charAt(0) === '_'){ | ||
return instance[key]; | ||
} | ||
return proxy(righto.sync(function(result){ | ||
traceGet(instance, result); | ||
return result[key]; | ||
@@ -102,0 +120,0 @@ }, instance)); |
{ | ||
"name": "righto", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "directories": { |
@@ -644,3 +644,3 @@ var test = require('tape'), | ||
var foo = stuff.foo | ||
var foo = stuff.foo; | ||
@@ -656,2 +656,48 @@ var bar = righto(function(foo, done){ | ||
test('proxy resolve', function(t){ | ||
t.plan(1); | ||
if(typeof Proxy === 'undefined'){ | ||
t.pass('Proxy not available'); | ||
return; | ||
} | ||
function getStuff(callback){ | ||
callback(null, {foo: 'foo'}); | ||
} | ||
var stuff = righto.proxy(getStuff); | ||
var foo = stuff.foo; | ||
var bar = righto.resolve({ foo }); | ||
bar(function(error, bar){ | ||
t.deepEqual(bar, { foo: 'foo' }); | ||
}); | ||
}); | ||
test('proxy resolve deep', function(t){ | ||
t.plan(1); | ||
if(typeof Proxy === 'undefined'){ | ||
t.pass('Proxy not available'); | ||
return; | ||
} | ||
function getStuff(callback){ | ||
callback(null, {foo: 'foo'}); | ||
} | ||
var stuff = righto.proxy(getStuff); | ||
var foo = stuff.foo; | ||
var bar = righto.resolve({ foo }, true); | ||
bar(function(error, bar){ | ||
t.deepEqual(bar, { foo: 'foo' }); | ||
}); | ||
}); | ||
test('resolve', function(t){ | ||
@@ -658,0 +704,0 @@ t.plan(1); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56843
1483