New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@stringstack/core

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stringstack/core - npm Package Compare versions

Comparing version
0.0.2
to
0.0.3
+16
test/lib/class.cycle-a.js
'use strict';
const TestBase = require( './class.base' );
class TestCycleA extends TestBase {
constructor( deps ) {
super( deps, 'TestCycleA' );
this._b = deps.get( './test/lib/class.cycle-b' );
}
}
module.exports = TestCycleA;
'use strict';
const TestBase = require( './class.base' );
class TestCycleB extends TestBase {
constructor( deps ) {
super( deps, 'TestCycleB' );
this._c = deps.get( './test/lib/class.cycle-c' );
this._g = deps.get( './test/lib/class.cycle-g' );
}
}
module.exports = TestCycleB;
'use strict';
const TestBase = require( './class.base' );
class TestCycleC extends TestBase {
constructor( deps ) {
super( deps, 'TestCycleC' );
this._d = deps.get( './test/lib/class.cycle-d' );
this._e = deps.get( './test/lib/class.cycle-e' );
}
}
module.exports = TestCycleC;
'use strict';
const TestBase = require( './class.base' );
class TestCycleD extends TestBase {
constructor( deps ) {
super( deps, 'TestCycleD' );
this._e = deps.get( './test/lib/class.cycle-e' );
}
}
module.exports = TestCycleD;
'use strict';
const TestBase = require( './class.base' );
class TestCycleE extends TestBase {
constructor( deps ) {
super( deps, 'TestCycleE' );
this._f = deps.get( './test/lib/class.cycle-f' );
this._i = deps.get( './test/lib/class.cycle-i' );
}
}
module.exports = TestCycleE;
'use strict';
const TestBase = require( './class.base' );
class TestCycleF extends TestBase {
constructor( deps ) {
super( deps, 'TestCycleF' );
}
}
module.exports = TestCycleF;
'use strict';
const TestBase = require( './class.base' );
class TestCycleG extends TestBase {
constructor( deps ) {
super( deps, 'TestCycleG' );
this._h = deps.get( './test/lib/class.cycle-h' );
}
}
module.exports = TestCycleG;
'use strict';
const TestBase = require( './class.base' );
class TestCycleH extends TestBase {
constructor( deps ) {
super( deps, 'TestCycleH' );
this._i = deps.get( './test/lib/class.cycle-i' );
this._c = deps.get( './test/lib/class.cycle-c' );
}
}
module.exports = TestCycleH;
'use strict';
const TestBase = require( './class.base' );
class TestCycleI extends TestBase {
constructor( deps ) {
super( deps, 'TestCycleI' );
}
}
module.exports = TestCycleI;
'use strict';
const TestBase = require( './class.base' );
class TestLoadApp extends TestBase {
constructor( deps ) {
super( deps, 'TestLoadApp' );
this._err_load_self = deps.get( 'app' );
}
}
module.exports = TestLoadApp;
'use strict';
const TestBase = require( './class.base' );
class TestLoadSelf extends TestBase {
constructor( deps ) {
super( deps, 'TestLoadSelf' );
this._err_load_self = deps.get( './test/lib/class.err.load-self' );
}
}
module.exports = TestLoadSelf;
+0
-2

@@ -16,3 +16,2 @@ 'use strict';

get( path ) {
// console.log( 'get path', this._path );
return this._loader.get( this._path, path );

@@ -22,3 +21,2 @@ }

set( path, value ) {
// console.log( 'set path', this._path );
return this._loader.set( this._path, path, value );

@@ -25,0 +23,0 @@ }

@@ -133,7 +133,9 @@ 'use strict';

if ( this._createsCycle( sourcePath, targetPath ) ) {
throw new Error( 'dependency cycle created' );
}
// only create one of everything
if ( this._components.hasOwnProperty( targetPath ) ) {
// console.log( 'already exists', targetPath );
// reset the init/dinit stacks to ensure this component initializes before everything that needs it

@@ -155,3 +157,2 @@ // and dinitializes after everything that needs it.

} catch ( e ) {
console.log( 'targetPathResolve', targetPathResolve );
throw e;

@@ -167,4 +168,2 @@ }

// this._checkCycle( sourcePath, targetPath );
let container = new Container( targetPath, this );

@@ -199,7 +198,4 @@ let instance = null;

// console.log( '_resetStacks', targetPath );
// move to start of init stack, items popped off
let initIndex = this._initializeStack.indexOf( targetPath );
// console.log( '_resetStacks initIndex', initIndex, targetPath );
if ( initIndex > -1 ) {

@@ -212,3 +208,2 @@ this._initializeStack.push( this._initializeStack[ initIndex ] );

let dinitIndex = this._dinitializeStack.indexOf( targetPath );
// console.log( '_resetStacks dinitIndex', dinitIndex, targetPath );
if ( dinitIndex > -1 ) {

@@ -301,3 +296,3 @@ this._dinitializeStack.push( this._dinitializeStack[ dinitIndex ] );

_checkCycle( sourcePath, targetPath, prefix ) {
_createsCycle( sourcePath, targetPath, prefix ) {

@@ -308,6 +303,4 @@ if ( typeof prefix !== 'string' ) {

console.log( prefix + '_checkCycle', sourcePath, targetPath );
// app is the meta root of all, so it always creates a cycle if someone includes it
if ( targetPath === 'app' ) {
if ( targetPath === 'app' || sourcePath === targetPath ) {
return true;

@@ -319,3 +312,3 @@ }

if ( !component ) {
console.log( '!component', targetPath );
return false;
}

@@ -330,3 +323,3 @@

cycleExists = this._checkCycle( sourcePath, dependencyPath, prefix + '\t' );
cycleExists = this._createsCycle( sourcePath, dependencyPath, prefix + '\t' );

@@ -333,0 +326,0 @@ } );

{
"name": "@stringstack/core",
"description": "StringStack Core",
"version": "0.0.2",
"version": "0.0.3",
"repository": {

@@ -6,0 +6,0 @@ "type": "git",

@@ -271,4 +271,2 @@ 'use strict';

// console.log( 'actualEvents', JSON.stringify( actualEvents, null, 4 ) );
try {

@@ -366,4 +364,2 @@

// console.log( 'actualEvents', JSON.stringify( actualEvents, null, 4 ) );
try {

@@ -557,4 +553,102 @@

it( 'should throw an error if component uses self as dependency', function () {
let core = new Core( {
rootModules: [
'./test/lib/class.err.load-self'
]
} );
let App = core.createApp();
let exception = null;
try {
let app = new App( 'test' );
} catch ( e ) {
exception = e;
}
assert.ok( exception, 'failed to throw exception' );
assert.equal( exception.message, 'dependency cycle created' );
} );
it( 'should allow shared dependency chains without cycles (dependency paths need not be a tree)', function ( done ) {
let core = new Core( {
rootModules: [
'./test/lib/class.cycle-a'
]
} );
let App = core.createApp();
let app = new App( 'test' );
// init/dinit over and over. It is up to the actual modules to ensure they reset their internal state
// correctly on subsequent init/dinit cycles.
async.series( [
checkInitialized( app, false ),
( done ) => {
app.init( done );
},
checkInitialized( app, true ),
( done ) => {
app.dinit( done );
},
checkInitialized( app, false ),
( done ) => {
let actualEvents = getComponent( app, './test/lib/class.cycle-a' )._getEvents();
let expectedEvents = [
"TestCycleA:instantiate",
"TestCycleB:instantiate",
"TestCycleC:instantiate",
"TestCycleD:instantiate",
"TestCycleE:instantiate",
"TestCycleF:instantiate",
"TestCycleI:instantiate",
"TestCycleG:instantiate",
"TestCycleH:instantiate",
"TestCycleI:init",
"TestCycleF:init",
"TestCycleE:init",
"TestCycleD:init",
"TestCycleC:init",
"TestCycleH:init",
"TestCycleG:init",
"TestCycleB:init",
"TestCycleA:init",
"TestCycleA:dinit",
"TestCycleB:dinit",
"TestCycleG:dinit",
"TestCycleH:dinit",
"TestCycleC:dinit",
"TestCycleD:dinit",
"TestCycleE:dinit",
"TestCycleF:dinit",
"TestCycleI:dinit"
];
// console.log( 'actualEvents', JSON.stringify( actualEvents, null, 4 ) );
try {
assert.deepStrictEqual( actualEvents,
expectedEvents,
'log of instantiation, initialization and d-initialization is not correct' );
} catch ( e ) {
return done( e );
}
done();
}
], done );
} );
} );
} );

@@ -29,3 +29,2 @@ 'use strict';

let value = this._name + ':' + eventName;
// console.log( '_testEvent', value );
events.push( value );

@@ -32,0 +31,0 @@ }