Skip to content

ArsalanImamverdi/tyInstance

Repository files navigation

tyInstance

tyInstance is a instance creator helper in typescript.

Installing

npm install tyinstance

Documentation

Here how to use the package:

Example 1

class ClassToCreate {
  constructor(public value: number, public name?: string) {}
}

class SomeClass {
  constructor() {
    let classToCreate = Instance.create(ClassToCreate, 100, 'Name');
  }
}

class SomeOtherClass {
  constructor() {
    let classToCreate = Instance.create(ClassToCreate, 10);
  }
}

Example 2

@Type({ name: 'SomeClassToCreate' })
class ClassToCreate {
  constructor(public value?: number) {}
}

class SomeClass {
  constructor() {
    let classToCreate = Instance.create('SomeClassToCreate', 100);
  }
}
class SomeOtherClass {
  constructor() {
    let classToCreate = Instance.create('SomeClassToCreate');
  }
}

Example 3

@Type() // If propery name doesn't pass, then the name of class would be the actual name of class , 'ClassToCreate'
class ClassToCreate {
  constructor(public value?: number) {}
}

class SomeClass {
  constructor() {
    let classToCreate = Instance.create('ClassToCreate', 100);
  }
}
class SomeOtherClass {
  constructor() {
    let classToCreate = Instance.create('ClassToCreate');
  }
}

Running Tests

To run tests, run the following command

  npm run test

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

Instance create helper

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published