New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@macfja/svelte-expirable

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@macfja/svelte-expirable

A Svelte store with items that expire

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

Svelte Expirable store

A Svelte store with items that expire

Installation

npm install @macfja/svelte-expirable

Usage

notification.js

import { expirable } from "@macfja/svelte-expirable"

export const notifications = expirable()

App.svelte

<script>
    import { notifications } from './notifications.js'
    
    const onClickHandler = () => {
        // Do some action
        notifications.push('Data saved', 2) // Message expire after 2 seconds
    }
</script>

<header>
    {#each $notifications as {data, id, repeated} (id)}
        <div class="message">{data}{#if repeated > 0} (x{repeated + 1}){/if}</div>
    {/each}
</header>

When the same data is push to the store, the expiration time is reset to the new TTL, and the repeated variable is incremented

Contributing

Contributions are welcome. Please open up an issue or create PR if you would like to help out.

Read more in the Contributing file

License

The MIT License (MIT). Please see License File for more information.

Keywords

FAQs

Package last updated on 03 Dec 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc