New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@gallink/oxygen

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gallink/oxygen

Bringing life to all the other Gallink applications.

latest
Source
npmnpm
Version
1.2.8
Version published
Maintainers
1
Created
Source

Oxygen brings life to other Gallink applications by providing a set of useful utilities.

Using Queues

Queues are a neat approach to processing a collection of items. Both of the implementations have different purposes, both which are particularly useful.

First is the standard Queue implementation, which is simply a box for an Array with the ability to dequeue items in a controlled, FIFO respect.

const friendsToAdd: Queue<Friend> = new Queue(api.getFriendSuggestions())

while (friendsToAdd.pending) {
    
    const friendToAdd: Friend = friendsToAdd.dequeue();
    
    await friendToAdd.sendFriendRequest() 
    
}

// Friends added!

PromiseQueue adds another layer of asynchronous debuffing to JavaScript by allowing you to queue Promises. We can rewrite the sample above to use these.

const friendsToAdd: Queue<Friend> = new Queue(api.getFriendSuggestions())
const friendsBeingAded: PromiseQueue<Friend> = new PromiseQueue<Friend>();

while (friendsToAdd.pending) {
    
    const friendToAdd: Friend = friendsToAdd.dequeue();
    
    await friendsBeingAdded.task(friendToAdd.sendFriendRequestAsync)
    
}

The difference between these two examples is that the first will handle all the friend requests at once, whereas the second example will handle one at a time.

Create Handleable Actions

Inspired by Node's EventEmitter, Actionable provides an attractive alternative to calling code in other places by firing actions that are listened to elsewhere - a professional use for callbacks.

const me: Person = new Person("Crowes");

me.on("hungry", me.eat())

Genuine Data Models

JavaScript does a poor job of supporting genuine data models, leaving you to write a lot of the boilerplate for a lot of your reflection-style work which is so commonly required in typical JavaScript applications.

const me: Person = new Person("Crowes", 21);
const differentMe: Person = new Person("Crowes", 22);

const difference: Map<string, any> = me.difference();
// { "age", 22 }

Keywords

Utilities

FAQs

Package last updated on 11 Jan 2019

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