Installations
npm install auto-bind-inheritance
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
8.5.0
NPM Version
5.5.1
Score
72.1
Supply Chain
98.9
Quality
75.5
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
cwingrav
Download Statistics
Total Downloads
162,083
Last Day
152
Last Week
588
Last Month
2,595
Last Year
26,761
GitHub Statistics
4 Stars
8 Commits
1 Forks
2 Watching
1 Branches
1 Contributors
Bundle Size
938.00 B
Minified
521.00 B
Minified + Gzipped
Package Meta Information
Latest Version
1.0.6
Package Id
auto-bind-inheritance@1.0.6
Size
3.13 kB
NPM Version
5.5.1
Node Version
8.5.0
Total Downloads
Cumulative downloads
Total Downloads
162,083
Last day
27.7%
152
Compared to previous day
Last week
-18.1%
588
Compared to previous week
Last month
20.1%
2,595
Compared to previous month
Last year
125.5%
26,761
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
auto-bind-inheritance
Automatically bind methods to their class instance and works on parent methods.
This package was created directly as a result of failing on extended classes in the auto-bind package.
There are issues with getters which are initialized in the constructor:
- initialize the getter/setter inside the getter/setter (not ideal)
- call autoBindI at end of final child (not ideal)
- manually call autoBindI
- avoid getter/setters
Install
$ npm install --save auto-bind-inheritance
Usage
1// const autoBind = require('auto-bind'); // drop-in replacement 2const autoBindI = require('auto-bind-inheritance'); 3 4class A { 5 constructor() { 6 this.val = 'A'; 7 autoBindI(this); 8 } 9 method2() { console.log('A.method2 ', this.val); } 10} 11 12class B extends A { 13 constructor() { 14 super(); 15 this.val = 'B'; 16 } 17 method1() { console.log('B.method1 ', this.val); } 18} 19 20 21let a = new A(); 22let b = new B(); 23 24 25b.method1(); 26b.method2(); 27let mb1 = b.method1; 28let mb2 = b.method2; 29console.log(mb1.name); 30console.log(mb2.name); 31mb1(); 32mb2(); 33 34 35// With `autoBind(this)`, the above could have resulted in: 36//=> 'B.method1 B' 37//=> 'A.method2 B' 38//=> 'bound bound method1' 39//=> 'method2' 40//=> 'B.method1 B' 41//=> 'exception "Cannot read property 'val' of undefined"' 42 43// With `autoBindI(this)`, the above now correctly results in bound and callable methods: 44//=> 'B.method1 B' 45//=> 'A.method2 B' 46//=> 'bound method1' 47//=> 'bound method2' 48//=> 'B.method1 B' 49//=> 'A.method2 B' 50 51 52
API
autoBind(self)
Bind methods in self
to their class instance. Returns the self
object. Can be placed in the parent and will be call on all child classes because the prototype chain has already been created.
self
Type: Object
Object with methods to bind.
Related
- auto-bind - Automatically bind methods to their class instance
License
MIT © Chad Wingrave
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
4 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
Reason
Found 0/8 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
2.5
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More