New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

djinn-state

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

djinn-state - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

1

dist/Djinn.d.ts

@@ -42,2 +42,3 @@ import { DjinnService } from './DjinnService';

start: () => void;
private __isValidService;
}

@@ -44,0 +45,0 @@ interface IDjinnServiceRegister {

@@ -38,3 +38,3 @@ "use strict";

var serviceName = anyService.name;
if (service.__proto__ !== DjinnService_1.DjinnService) {
if (!_this.__isValidService(service)) {
console.error("Tried to register an invalid Service Class: \"" + serviceName + "\".\nDjinn services must extends the class \"DjinnService\".");

@@ -111,4 +111,13 @@ return;

}
Djinn.prototype.__isValidService = function (service) {
if (!service.__proto__) {
return false;
}
if (service.__proto__ === DjinnService_1.DjinnService) {
return true;
}
return this.__isValidService(service.__proto__);
};
return Djinn;
}());
exports.Djinn = Djinn;

2

package.json
{
"name": "djinn-state",
"version": "1.2.1",
"version": "1.3.0",
"description": "Powerful yet simple state machine",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -15,3 +15,6 @@ import { Djinn } from '../Djinn';

class InheritedService extends FakeService {
}
describe('Djinn', () => {

@@ -52,2 +55,11 @@ it('should be creating a new Djinn instance', () => {

it('should register an inherited service', () => {
const djinn = new Djinn();
djinn.register(InheritedService);
djinn.start();
const service = djinn.getService(InheritedService);
expect(service).toBeDefined();
});
it('should return an instance of a registered Service', () => {

@@ -54,0 +66,0 @@ const djinn = new Djinn();

import { DjinnService } from './DjinnService';
import { forEachToken } from 'tslint';

@@ -30,3 +29,3 @@

if ((<any>service).__proto__ !== DjinnService) {
if (!this.__isValidService(service)) {
console.error(`Tried to register an invalid Service Class: "${serviceName}".\nDjinn services must extends the class "DjinnService".`);

@@ -59,3 +58,3 @@ return;

getService = <T>(service: new () => T): T => {
const serviceName = (<any>service).name;
const serviceName = (service as any).name;

@@ -69,3 +68,3 @@ const registeredService = this.__services[serviceName];

if (registeredService.scoped) {
const ServiceClass = <any>registeredService.service;
const ServiceClass = (registeredService as any).service;
const serviceInstance = new ServiceClass();

@@ -84,3 +83,3 @@ serviceInstance.initService();

remove = (service: any) => {
const serviceName = (<any>service).name;
const serviceName = (service as any).name;
delete this.__services[serviceName];

@@ -107,2 +106,14 @@ delete this.__servicesSingletons[serviceName];

};
private __isValidService(service: any): boolean {
if (!service.__proto__) {
return false;
}
if (service.__proto__ === DjinnService) {
return true;
}
return this.__isValidService(service.__proto__);
}
}

@@ -109,0 +120,0 @@

Sorry, the diff of this file is not supported yet

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