
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
@mornya/eventable-storage-libs
Advanced tools
The project of Eventable & Expirable Storage library.
This project has been created by Vessel CLI. For a simple and quick reference about it, click here.
์น์คํ ๋ฆฌ์ง(window.Storage)์ Storage ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ localStorage, sessionStorage ์ฌ์ฉ์ ์ ์ฅ๋ ๋ฐ์ดํฐ ๋ณ๊ฒฝ์ ๋ฐ๋ฅธ ์ด๋ฒคํธ๋ฅผ ๋ฐ์์์ผ์ค๋ค.
ํด๋น ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉ ํ ํ๋ก์ ํธ์์๋ ์๋์ ๊ฐ์ด ์์กด์ฑ ๋ชจ๋๋ก ์ค์นํ๋ค.
$ npm install --save @mornya/eventable-storage-libs
or
$ yarn add @mornya/eventable-storage-libs
๊ธฐ๋ณธ์ ์ธ ์ฌ์ฉ๋ฐฉ๋ฒ์ ์๋์ ๊ฐ๋ค.
ํ์
์คํฌ๋ฆฝํธ ์ฌ์ฉ์ window.Storage์ ๋ํ ๊ธ๋ก๋ฒ ํ์
์ฌ์ ์ธ์ด ํ์ํ๋ฏ๋ก ๋จผ์ tsconfig.tson ํ์ผ์ ํ์
์ด ์ฐธ์กฐ๋๋๋ก ์ถ๊ฐํ๋ค.
{
...
"typeRoots": [
"./node_modules/@mornya/eventable-storage-libs/dist"
],
...
}
์ ํ๋ฆฌ์ผ์ด์ ๊ตฌ๋ ์ด๊ธฐ์ ํ์ฑํ๋ฅผ ์ํด ์๋์ ๊ฐ์ด ์ฝ๋๋ฅผ ์ถ๊ฐํ๋ค.
import { EventableStorage } from '@mornya/eventable-storage-libs';
if (!EventableStorage.isAvailableStorage('localStorage')) {
console.error('window.localStorage๋ฅผ ์ฌ์ฉ ํ ์ ์์ต๋๋ค!');
} else {
...
EventableStorage.initialize(true);
...
}
EventableStorage์์ ๋ฐ์๋๋ ์ด๋ฒคํธ๋ฅผ ํ์ฉํ๊ธฐ ์ํด์๋ ์๋์ ๊ฐ์ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๋ค.
import { EventableStorage } from '@mornya/eventable-storage-libs';
const eventHandler = (event) => {
console.log(event.detail); // { action: 'set', key: 'foo', value: 'bar' }
};
window.addEventListener('eventableStorage', handler, false);
window.localStorage.setItem('foo', 'bar');
window.removeEventListener('eventableStorage', handler, false);
ํน์ ์ ๊ณต๋๋ ๋ฉ์๋๋ฅผ ์ฌ์ฉํ๋ค (์์ ๋์ผํ ์คํ์ด์ง๋ง ๋ฆฌ์ค๋ ๋ฑ๋ก ํ์ฉ ๊ฐฏ์ ์ ํ์ด ์๋ค).
import { EventableStorage } from '@mornya/eventable-storage-libs';
const eventHandler: EventableStorage.Listener = (detail: Detail) => {
console.log(detail); // { action: 'set', key: 'foo', value: 'bar' }
};
EventableStorage.addListener(eventHandler);
window.localStorage.setItem('foo', 'bar');
EventableStorage.removeListener(eventHandler);
Storage ๊ฐ์ฒด ๋ด ์ ๊ณต๋๋ ๋ฉ์๋๋ค์ ์๋์ ๊ฐ๋ค.
getItem์คํ ๋ฆฌ์ง์ ์ ์ฅ๋ ๊ฐ์ ์ป์ด์จ๋ค.
window.localStorage.getItem(key);
window.sessionStorage.getItem(key);
setItem์คํ ๋ฆฌ์ง์ ๊ฐ์ ์ ์ฅํ๋ค. ๋ง๋ฃ์ผ์(Dateํ์
)๋ฅผ ์ง์ ํ ์ ์๋ค. getItem์ผ๋ก ์คํ ๋ฆฌ์ง์ ์ ์ฅ๋ ๊ฐ์ ์ฝ์ด์ฌ ๋ ๋ง๋ฃ์ผ์๊ฐ ์ง๋ฌ๋ค๋ฉด ํด๋น ํค๋ก ์ ์ฅ๋ ๊ฐ์ด ์คํ ๋ฆฌ์ง์์ ์ ๊ฑฐ๋๋ฉฐ, null์ด ๋ฐํ๋๋ค.
window.localStorage.setItem(key, value[, expireDate]);
window.sessionStorage.setItem(key, value[, expireDate]);
removeItem์คํ ๋ฆฌ์ง์ ์ ์ฅ๋ ๊ฐ์ ์ ๊ฑฐํ๋ค.
window.localStorage.removeItem(key);
window.sessionStorage.removeItem(key);
clear์คํ ๋ฆฌ์ง์ ์ ์ฅ๋ ๊ฐ์ ๋ชจ๋ ์ ๊ฑฐํ๋ค.
window.localStorage.clear();
window.sessionStorage.clear();
setExpire์กด์ฌํ๋ ์คํ ๋ฆฌ์ง ๊ฐ์ ๋ง๋ฃ ๊ฐ๋ฅํ ์ํ๋ก ๋ง๋ ๋ค. isEventable ๊ฐ์ด true๋ก ์ค์ ๋๋ฉด ์์ฑ์ ์ด๋ฒคํธ๋ฅผ ๋ฐ์ํ๋ค.
window.localStorage.setExpire(key, expireDate[, isEventable]);
window.sessionStorage.setExpire(key, expireDate[, isEventable]);
keys์กด์ฌํ๋ ์คํ ๋ฆฌ์ง ํค ๋ชฉ๋ก์ ๋ฆฌํดํ๋ค. ์คํ ๋ฆฌ์ง ๊ฐ ๋ง๋ฃ๋ฅผ ์ํด ์์ฑ๋๋ *.exp ํํ์ ํค๋ ์ ์ธ๋๋ค.
window.localStorage.keys();
window.sessionStorage.keys();
๋ณธ ํจํค์ง์๋ ์๋์ ๊ฐ์ ๋ชจ๋๋ค์ ํฌํจํ๋ค.
์ ๊ณต๋๋ ๋ชจ๋๊ณผ ๋ฉ์๋ ์ฌ์ฉ๋ฒ ๋ฑ์ ์ฝ๋ ์ค๋ํ์ ์ฐธ๊ณ ํ๋ค.
window.Storage ๊ฐ์ฒด ์กด์ฌ ์ฌ๋ถ ํ์ธ.
import { isAvailableStorage } from '@mornya/eventable-storage-libs';
const result = isAvailableStorage('localStorage');
console.log(result); // true or false
EventableStorage ๋ชจ๋์ ๋ค์๊ณผ ๊ฐ์ ๋ฉ์๋๋ค์ ์ ๊ณตํ๋ค.
EventableStorage.initialize์ด๊ธฐํ๋ฅผ ์ํด ์ฑ ์คํ์์ (์ต์ด)์ ์คํํ๋ค. ์ฌ๋ฌ ๋ฒ ํธ์ถํด๋ 1ํ๋ง ์คํ๋๋ค. isActive ํ๋ผ๋ฏธํฐ ๊ฐ์ ๊ธฐ๋ณธ์ ์ผ๋ก false ์ด๋ฏ๋ก, ๋ฐ๋ก ํ์ฑํ ํ์์ ํ๋ผ๋ฏธํฐ๋ฅผ true๋ก ์ฃผ๊ฑฐ๋, EventableStorage.setActive(true) ๋ฉ์๋๋ฅผ ์คํํด์ผ ํ๋ค.
function initialize (isActive: boolean): boolean {}
EventableStorage.isActiveEventableStorage ํ์ฑํ ํน์ ๋นํ์ฑํ ์ฌ๋ถ๋ฅผ ๋ฆฌํดํ๋ค.
function isActive (): boolean {}
EventableStorage.setActiveEventableStorage ํ์ฑํ ํน์ ๋นํ์ฑํ ์ฒ๋ฆฌํ๋ค.
function setActive (flag: boolean): void {}
EventableStorage.getMaxListenersํ์ฉ ๊ฐ๋ฅํ ์ด๋ฒคํธ ๋ฆฌ์ค๋ ๋ฑ๋ก ๊ฐฏ์๋ฅผ ๋ฆฌํดํ๋ค.
function getMaxListeners (): number {}
EventableStorage.setMaxListenersํ์ฉ ๊ฐ๋ฅํ ์ด๋ฒคํธ ๋ฆฌ์ค๋ ๋ฑ๋ก ๊ฐฏ์๋ฅผ ์ค์ ํ๋ค.
function setMaxListsners (max: number): void {}
EventableStorage.addListenereventableStorage ๋ฆฌ์ค๋๋ฅผ ๋ฑ๋กํ๋ค. ๋ฑ๋ก๋ ๋ฆฌ์ค๋์ ๊ฐฏ์๋ฅผ ๋ฆฌํดํ๋ค.
function addListener (listener: Listener): number {}
๋ฆฌ์ค๋ ๋ฑ๋ก์ ์๋์ ๊ฐ์ด ๋ ๊ฐ์ง ๋ฐฉ๋ฒ ์ค ํ๋๋ก ํ๋ค.
// ํธ๋ค๋ฌ ์ ์ธ
function myEventHandler () { ... }
EventableStorage.addListener(myEventHandler);
/* ํน์ */
window.addEventListener('eventableStorage', myEventHandler, false);
EventableStorage.removeListenereventableStorage ๋ฆฌ์ค๋๋ฅผ ํด์ ํ๋ค. ๋ฑ๋ก๋ ๋ฆฌ์ค๋์ ๊ฐฏ์๋ฅผ ๋ฆฌํดํ๋ค.
function removeListener (listener: Listener): number {}
๋ฆฌ์ค๋ ํด์ ๋ ์๋์ ๊ฐ์ด ๋ ๊ฐ์ง ๋ฐฉ๋ฒ ์ค ํ๋๋ก ํ๋ค.
// ํธ๋ค๋ฌ ์ ์ธ
function myEventHandler () { ... }
EventableStorage.removeListener(myEventHandler);
/* ํน์ */
window.removeEventListener('eventableStorage', myEventHandler);
ํ๋ก์ ํธ ๋ณ๊ฒฝ์ฌํญ์ CHANGELOG.md ํ์ผ ์ฐธ์กฐ.
ํ๋ก์ ํธ ๋ผ์ด์ผ์ค๋ LICENSE ํ์ผ ์ฐธ์กฐ.
FAQs
The project of Eventable & Expirable Storage library.
We found that @mornya/eventable-storage-libs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.ย It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authoritiesโ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socketโs new workflow scanning support.