Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iguntur/proto-exists
https://github.com/iguntur/proto-exists
Last synced: about 11 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/iguntur/proto-exists
- Owner: iguntur
- License: mit
- Created: 2017-02-18T19:51:58.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-02-18T22:50:51.000Z (over 7 years ago)
- Last Synced: 2024-10-12T17:58:27.424Z (26 days ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# proto-exists [![Build Status](https://travis-ci.org/iguntur/proto-exists.svg?branch=master)](https://travis-ci.org/iguntur/proto-exists)
> Check if prototype exists and prototype is a function
## Install
```
$ npm install --save proto-exists
```## Usage
```js
const protoExists = require('proto-exists');class Foo {
constructor() {
this.bar = '⚛';
this.barQuux = () => '⚇';
}
baz() {
return this.bar;
}
get getter() {
return this.bar;
}
set setter(input) {
this.bar = input;
}
}// returns true
protoExists(Foo, 'baz');
protoExists(new Foo(), 'baz');// returns false
protoExists(Foo, 'notExists');
protoExists(Foo, 'barQuux');
protoExists(Foo, 'bar');
protoExists(Foo, 'getter');
protoExists(Foo, 'setter');
protoExists(new Foo(), 'notExists');
protoExists(new Foo(), 'bar');
```## API
### protoExists(construct, name)
Returns a boolean value.
#### construct
Type: ``, ``
A constructor function.
#### name
Type: `string`
The prototype name of constructor.
## License
MIT © [Guntur Poetra](http://iguntur.starmediateknik.com)