@trademe/ensure
Advanced tools
Comparing version 0.1.0-beta.3 to 0.1.0-beta.4
@@ -5,3 +5,2 @@ "use strict"; | ||
var ensure_error_1 = require("../ensure-error"); | ||
var core_1 = require("@angular/core"); | ||
function Singleton() { | ||
@@ -17,11 +16,2 @@ return function (injectable) { | ||
exports.Singleton = Singleton; | ||
// @Singleton must appear before the @Injectable decorator on the class. | ||
// This is so the service injection is applied to the original class. | ||
function checkInjectable(injectable) { | ||
var annotations = Reflect.getOwnMetadata('annotations', injectable); | ||
var isInjectable = annotations && annotations.some(function (ann) { return ann.constructor === core_1.Injectable; }); | ||
if (!isInjectable) { | ||
throw new ensure_error_1.EnsureError("\n @Singleton must appear before @Injectable:\n\n @Singleton()\n @Injectable()\n export class " + injectable.name + " { }\n "); | ||
} | ||
} | ||
function createSingleton(injectable) { | ||
@@ -31,3 +21,2 @@ var instantiated = null; | ||
if (!instantiated) { | ||
checkInjectable(injectable); | ||
instantiated = true; | ||
@@ -34,0 +23,0 @@ this._reset = function () { return instantiated = false; }; |
{ | ||
"name": "@trademe/ensure", | ||
"version": "0.1.0-beta.3", | ||
"version": "0.1.0-beta.4", | ||
"description": "Utility decorators for Angular applications", | ||
@@ -12,3 +12,3 @@ "main": "dist/index.js", | ||
"compile": "ngc -p ./tsconfig.json && tsc -p ./tsconfig.json", | ||
"cover": "ts-node node_modules/istanbul/lib/cli.js cover --config .istanbulrc.json _mocha -- --opts ./.mocharc \"src/**/*.spec.ts\"", | ||
"cover": "ts-node node_modules/istanbul/lib/cli.js cover --config .istanbulrc.json node_modules/mocha/bin/_mocha -- --opts ./.mocharc \"src/**/*.spec.ts\"", | ||
"test": "mocha --opts ./.mocharc \"src/**/*.spec.ts\"" | ||
@@ -15,0 +15,0 @@ }, |
Sorry, the diff of this file is not supported yet
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
56217
176