think-instance
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "think-instance", | ||
"description": "add .getInstance method for class", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "welefen", |
# think-instance | ||
[![Build Status](https://travis-ci.org/thinkjs/think-instance.svg?branch=master)](https://travis-ci.org/thinkjs/think-instance) | ||
[![Coverage Status](https://coveralls.io/repos/github/thinkjs/think-instance/badge.svg)](https://coveralls.io/github/thinkjs/think-instance) | ||
[![npm](https://img.shields.io/npm/v/think-instance.svg)](https://www.npmjs.com/package/think-instance) | ||
## Install | ||
@@ -4,0 +8,0 @@ |
@@ -109,3 +109,21 @@ import test from 'ava'; | ||
test('get instance, set max & close 3', t => { | ||
let close = 0; | ||
let cls = class { | ||
constructor(index){ | ||
this.index = index; | ||
} | ||
close(){ | ||
close += this.index; | ||
} | ||
} | ||
cls = thinkInstance(cls, 1, 'close'); | ||
const instance1 = cls.getInstance(2); | ||
const instance2 = cls.getInstance(3); | ||
const instance3 = cls.getInstance(4); | ||
t.is(close, 5); | ||
}); | ||
test('get instance with multi args', t => { | ||
@@ -112,0 +130,0 @@ let cls = class { |
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
8254
165
24