npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

catwalk.js

v2.0.0

Published

Intuitive and fast relational CRUD interface for modelling relationships using vanilla objects written in ES6.

Downloads

94

Readme

Catwalk

Travis   npm   License MIT

  • npm: npm install catwalk

Catwalk is a CRUD interface that allows you to lazy-load your data. It's written in ES6 and transpiled to ES5 using Google's Traceur module. By using Catwalk you interact with simple CRUD events using promises to either resolve or reject a certain action – there are absolutely no convoluted methods or sequences that materialised in Ember Data.

Getting Started

import {collection} from 'catwalk/collection';
import {field, cast} from 'catwalk/field';
import {on, type} from 'catwalk/event';

// Define a collection specifying its fields and their data-types.
const pets = collection('pets', {
    name: field(cast.string()),
    age:  field(cast.integer())
});

// Subscribe to the updating of any collections.
on(type.SUBSCRIBE, store => {
    console.log(`We have ${store.pets.length} pet(s)!`);
});

// Consider the request successful when we create a pet.
on(type.CREATE, ({ model, resolve, reject }) => {
    resolve(model);
});

// Create some pets that need to be either resolved or rejected.
pets.create({ name: 'Miss Kittens', age: 4 });
pets.create({ name: 'Busters', age: 5 });

Event Types

Each operation has a corresponding event — type.CREATE, type.READ, type.UPDATE, type.DELETE — and can be registering using the on function from catwalk/event.

on(type.CREATE, () => // ...);

However there are instances where you'd rather listen for these events on a specific collection, in cases where you wish to specialise rather than abstract. In these instances you can use the for method on each event type.

on(type.CREATE.for(pets), () => // ...);

Note: When a specialised event type has been registered, then its abstract counterpart will not be invoked for that collection. In the above case, the type.CREATE.for(pets) event will be invoked, but type.CREATE for the pets collection will not.

Events can also be unregistered with the off function — passing in the symbol that was initially used to register it.

off(type.CREATE.for(pets));

Transactions (Future)

Note: Transactions are not yet supported, and the example below is how it may look once implemented.

import {atomic} from 'catwalk/transaction';

atomic(async function({ commit, rollback }) {
    await pets.create({ name: 'Miss Kittens', age: 4 });
    await pets.create({ name: 'Busters', age: 5 });
    rollback();
);