Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@oada/list-lib

Package Overview
Dependencies
Maintainers
8
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oada/list-lib

Library for processing items in an OADA list

  • 4.2.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-91.3%
Maintainers
8
Weekly downloads
 
Created
Source

@oada/list-lib

npm Downloads/week code style: prettier License

A library for handling lists of items in OADA for TypeScript and JavaScript. The library takes callbacks for events like new items, removed items, and changed items. It tried to abstract away as much of the complexity as is reasonable, and tracks which items in the list are new, old, etc.

For detailed options, see the Options type in src/Options.ts

Basic Usage Example

import { ChangeType, ListWatch } from '@oada/list-lib'

// See type definitions for all supported options
const watch = new ListWatch({
    path: '/bookmarks/foo/list',
    conn: /* an @oada/client instance */,
})

// Uses async generators
const itemsGenerator = await watch.on(ChangeType.ItemAdded);
for await (const item of itemsGenerator) {
    console.log(item, 'New item added');
}

// Can use callbacks instead
watch.on(ChangeType.ItemAdded, ({ item, id }) => { console.log(item, 'New list item') });
watch.on(ChangeType.ItemRemoved, ({ id }) => { console.log(item, 'Item removed') },

Item types

While the ListWatch class is generic, you will typically not want to specify a type parameter in your code. If you supply an assertItem function, the type of Item will be inferred from it. This will help minimize runtime errors (assuming your type assertion is good), and in the case of no assertion, the library defaults Item to unknown.

Rechecking items

In more advanced use cases, you might want to prompt the library to re-check all the items in the list. For this reason, ListWatch has a forceRecheck method. Calling this will cause the library to check all the current list items.

FAQs

Package last updated on 03 Feb 2023

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