Installations
npm install extern-constantify
Developer Guide
Typescript
No
Module System
CommonJS
NPM Version
1.4.9
Score
58.5
Supply Chain
91.6
Quality
74.6
Maintenance
100
Vulnerability
99.6
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
call-a3
Download Statistics
Total Downloads
1,577
Last Day
2
Last Week
2
Last Month
4
Last Year
65
GitHub Statistics
12 Commits
2 Watching
2 Branches
1 Contributors
Bundle Size
106.85 kB
Minified
32.42 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.2.0
Package Id
extern-constantify@0.2.0
Size
3.18 kB
NPM Version
1.4.9
Total Downloads
Cumulative downloads
Total Downloads
1,577
Last day
0%
2
Compared to previous day
Last week
0%
2
Compared to previous week
Last month
-20%
4
Compared to previous month
Last year
-33%
65
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
extern-constantify
Browserify transform that allows does in-place replacement of global constants, without having to declare them or import them at every occurence.
Installation
Usage
1browserify -t extern-constantify entry.js > bundle.js
Example
For example, suppose you have different classes/objects in your project communicating by events/messages:
1var Sender = function () { 2 this.emit('begin'); 3 //do some stuff, reporting progress 4 this.emit('busy', progress); 5 //finalize and report success 6 this.emit('done'); 7}; 8 9var Receiver = function (sender) { 10 sender.on('begin', function(data) { 11 node.innerHTML = 'Starting...'; 12 }); 13 sender.on('busy', function(data) { 14 node.innerHTML = 'Work is ' + data + '% complete'; 15 }); 16 sender.on('done', function(data) { 17 node.innerHTML = 'Work is done'; 18 }); 19};
Now suppose you later decide to change the names of these events to start
, progress
and end
. You would have to look for the various occurences of the original literal strings in your code and replace them accordingly. This introduces a lot of room for error. Instead you could write this:
1var Sender = function () { 2 this.emit(BEGIN_EVENT); 3 //do some stuff, reporting progress 4 this.emit(BUSY_EVENT, progress); 5 //finalize and report success 6 this.emit(END_EVENT); 7}; 8 9var Receiver = function (sender) { 10 sender.on(BEGIN_EVENT, function(data) { 11 node.innerHTML = 'Starting...'; 12 }); 13 sender.on(BUSY_EVENT, function(data) { 14 node.innerHTML = 'Work is ' + data + '% complete'; 15 }); 16 sender.on(END_EVENT, function(data) { 17 node.innerHTML = 'Work is done'; 18 }); 19};
and provide the following configuration in your package.json
file
1{ 2 "extern-constantify": { 3 "BEGIN_EVENT": "begin", 4 "BUSY_EVENT": "busy", 5 "END_EVENT": "done" 6 } 7}
The aforementioned change would then only require one edit in your configuration instead of the multiple edits that were previously required.
The matching happens case-sensitively, so you can avoid naming conflicts by uppercasing all characters of a constant name. This is the recommended coding style, however it is not mandatory.
License
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 0/5 approved changesets -- score normalized to 0
Reason
project is archived
Details
- Warn: Repository is archived.
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
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
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 9 are checked with a SAST tool
Score
3
/10
Last Scanned on 2024-12-30
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