var fibers= require( 'fibers' ) | ||
var proxy= require( 'jin/proxy' ) | ||
var sync= require( 'jin/sync' ) | ||
var lazy= require( 'jin/lazy' ) | ||
@@ -13,18 +14,18 @@ var fiberize= | ||
function( base, name ){ | ||
var value= base[ name ] | ||
if( !fibers.current ) | ||
return value | ||
return base[ name ] | ||
var chunks= /^(.*)Sync$/.exec( name ) | ||
var chunks= /^(.+)Sync(Now)?$/.exec( name ) | ||
if( !chunks ){ | ||
if(( base == null )||( typeof base !== 'object' )) | ||
return value | ||
return base[ name ] | ||
return fiberize( value ) | ||
return fiberize( base[ name ] ) | ||
} | ||
value= base[ chunks[ 1 ] ] | ||
name= chunks[ 1 ] | ||
var now= chunks[ 2 ] | ||
var value= sync( base[ name ], now ) | ||
return sync( value ) | ||
return value | ||
} | ||
@@ -31,0 +32,0 @@ |
@@ -21,4 +21,4 @@ var fiberizer= require( 'jin/fiberizer' ) | ||
var $= loader() | ||
$.npm.loadSync( {} ).valueOf() | ||
$.npm.commands.installSync([ path ]).valueOf() | ||
$.npm.loadSyncNow( {} ) | ||
$.npm.commands.installSyncNow([ path ]) | ||
} catch( error ){ | ||
@@ -33,25 +33,3 @@ console.log( error.stack ) | ||
this.apply= | ||
function( target, self, args ){ | ||
var func= args[ 0 ] | ||
var callback= args[ 1 ] | ||
var $= loader() | ||
var proc= | ||
callback | ||
? function( ){ | ||
try { | ||
var result= func.apply( this, arguments ) | ||
} catch( err ){ | ||
var error= err | ||
} | ||
callback( error, result ) | ||
} | ||
: func | ||
var fibers= $.fibers | ||
return fibers( proc ).run( $ ) | ||
} | ||
} )( {} ) | ||
} |
{ | ||
"name": "jin", | ||
"version": "1.3.1", | ||
"version": "1.5.0", | ||
"description": "Harmoy node.js sugar full-async framework", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/nin-jin/node-jin", |
@@ -48,2 +48,3 @@ if( typeof Proxy === 'undefined' ) | ||
function( receiver, name ){ | ||
if( name === 'toString' ) return function(){ return String( target ) } | ||
return handler.get ? handler.get( target, name, receiver ) : target[ name ] | ||
@@ -50,0 +51,0 @@ } |
@@ -45,3 +45,3 @@ node-jin | ||
require( 'jin' )( function( $ ){ | ||
require( 'jin' ).application( function( $ ){ | ||
var app= $.connect( $.connect.static( 'public' ) ) | ||
@@ -54,2 +54,39 @@ $.http.createServer( app ).listen( 8080 ) | ||
Persistent | ||
------------------- | ||
When your application has crashed or when its files has updated, you need to restart application. This is monkey job. To reduce it, wrap your application to $.jin.persistent: | ||
require( 'jin' ).persistent( function( $ ){ | ||
$.connect() | ||
.use( function( req, res ){ | ||
res.end( 'hello world!' ) | ||
} ) | ||
.listen( 80 ) | ||
} ) | ||
That is all :) How it works? $.jin.persistent forks main module and run callback in child process. And restart it when needed. Example of console output while i has editing this simple application: | ||
>node --harmony . | ||
$.jin.persistent: Starting application... | ||
$.jin.persistent: Some files changed! | ||
$.jin.persistent: Starting application... | ||
C:\OpenServer\domains\node.test\index.js:5 | ||
res.end( 'hello world!! ) | ||
^^^^^^^^^^^^^^^^ | ||
SyntaxError: Unexpected token ILLEGAL | ||
at Module._compile (module.js:437:25) | ||
at Object.Module._extensions..js (module.js:467:10) | ||
at Module.load (module.js:356:32) | ||
at Function.Module._load (module.js:312:12) | ||
at Module.runMain (module.js:492:10) | ||
at process.startup.processNextTick.process._tickCallback (node.js:244:9) | ||
$.jin.persistent: Application halted (1) | ||
$.jin.persistent: Some files changed! | ||
$.jin.persistent: Starting application... | ||
SOD | ||
@@ -64,3 +101,3 @@ --- | ||
require( 'jin' )( function( $ ){ | ||
require( 'jin' ).application( function( $ ){ | ||
@@ -67,0 +104,0 @@ function get( ){ |
11
sync.js
var fibers= require( 'fibers' ) | ||
var proxy= require( 'jin/proxy' ) | ||
var lazy= require( 'jin/lazy' ) | ||
var sync= | ||
function( func ){ | ||
function( func, now ){ | ||
return proxy | ||
@@ -37,7 +36,7 @@ ( new function( ){ | ||
return lazy( function( ){ | ||
var get= function( ){ | ||
if( !done ){ | ||
fiber= fibers.current | ||
fibers.yield() | ||
if( error ) error.stack+= '\n--fiber--\n' + stack //.replace( /^(?:[^\n]*\n){2}/, '\n' ) | ||
if( error ) error.stack+= '\n--fiber--\n' + stack | ||
} | ||
@@ -47,3 +46,5 @@ | ||
return result | ||
} ) | ||
} | ||
return now ? get() : lazy( get ) | ||
} | ||
@@ -50,0 +51,0 @@ } |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
25691
14.1%17
21.43%502
10.82%211
21.26%6
50%