Gathering detailed insights and metrics for @egjs/component
Gathering detailed insights and metrics for @egjs/component
Gathering detailed insights and metrics for @egjs/component
Gathering detailed insights and metrics for @egjs/component
A class used to manage events in a component like DOM
npm install @egjs/component
99.2
Supply Chain
100
Quality
83.1
Maintenance
100
Vulnerability
100
License
3.0.5 Release (2023-10-20)
Published on 20 Oct 2023
3.0.4 Release (2022-12-29)
Published on 29 Dec 2022
3.0.3 Release (2022-12-15)
Published on 15 Dec 2022
3.0.2 Release (2021-10-27)
Published on 07 Oct 2022
3.0.1 Release (2021-03-11)
Published on 11 Mar 2021
3.0.0 Release (2021-03-04)
Published on 04 Mar 2021
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
38 Stars
138 Commits
9 Forks
12 Watching
3 Branches
14 Contributors
Updated on 26 Feb 2024
Minified
Minified + Gzipped
TypeScript (71.18%)
JavaScript (28.82%)
Cumulative downloads
Total Downloads
Last day
-12.3%
21,878
Compared to previous day
Last week
1.8%
126,819
Compared to previous week
Last month
5.7%
533,987
Compared to previous month
Last year
68%
4,915,718
Compared to previous year
42
A class used to manage events and options in a component
Download dist files from repo directly or install it via npm.
You can download the uncompressed files for development
You can download the compressed files for production
The following command shows how to install egjs-component using npm.
1$ npm install @egjs/component
The following are the supported browsers.
Internet Explorer | Chrome | Firefox | Safari | iOS | Android |
---|---|---|---|---|---|
7+ | Latest | Latest | Latest | 7+ | 2.1+(except 3.x) |
1<script src="../dist/component.js"></script>
1import Component from "@egjs/component"; 2 3class Some extends Component { 4 hi() { 5 alert("hi"); 6 } 7 thing() { 8 this.once("hi", this.hi); 9 } 10} 11 12var some = new Some(); 13some.thing(); 14some.trigger("hi"); 15// fire alert("hi"); 16some.trigger("hi"); 17// Nothing happens
You can use Typescript Generics to define events that component can emit.
1import Component, { ComponentEvent } from "@egjs/component"; 2 3interface Events { 4 event1: { 5 prop1: number; 6 prop2: string; 7 }; 8 // You can also define like this if there're more than one arguments for a event 9 event2: (arg0: number, arg1: string, arg2: boolean) => void; 10 // If there're no event props 11 event3: void; 12 // If you want additional properties like `currentTarget`, `eventType`, `stop` 13 // You can use ComponentEvent with additional properties 14 event4: ComponentEvent<{ a: number; b: string }>; 15} 16 17class SomeClass extends Component<Events> { 18 thing() { 19 this.on("event4", e => { 20 // These properties will be available for typescript-enabled environment 21 e.a; // number 22 e.b; // string 23 e.currentTarget; // SomeClass(this) 24 e.eventType; // string("event4") 25 e.stop(); // () => void 26 e.isCanceled(); // Will return true when "stop()" is called. 27 }); 28 } 29} 30 31// You can trigger events like this 32const component = new SomeClass(); 33component.trigger("event1", { 34 prop1: 1, 35 prop2: "abc" 36}); 37component.trigger(new ComponentEvent("event4", { a: 123, b: "abcd" }));
If you find a bug, please report it to us using the Issues page on GitHub.
@egjs/component is released under the MIT license.
Copyright (c) 2015 NAVER Corp.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 7/20 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
73 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
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