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

vuex-single-src

v0.0.3

Published

Vuex Plugin for providing a single data source to the state tree via branch mappings

Downloads

5

Readme

Collo | An npm package for managing collection functions

(Pronounced Call-O)! Super lightweight (No dependencies) utility package for dealing with in memory collections. It's like Mongoose and Lodash in one. It's like Collections Lodash [Col Lo].

Getting started

  1. From Command Line run npm i -S collo
import Collo from 'collo';

const myCollection = [
    {
        id: 1,
        name: 'pigeon'
    },
    {
        id: 2,
        name: 'badger'
    },
    {
        id: 3,
        name: 'squirrel'
    }
];

const collection = new Collo(myCollection);

Usage

To Promisify the response : After you instantiate Collo, and before you use the api, trigger promisification. You can use chaining or you can call collection.promisify() by itself. The same is true of unpromisify.

const collection = new Collo(myCollection);

collection
    .promisify()
    .list()
    .then(items=>console.log(items))
    .catch(err=>console.log(err));

New collections are Observable.

There is a next and error fn on the instance that streams results on change or on error respectively.

collection
	.subscribe(
		res=>console.log('NEXT ',res),
		err=>console.log('ERROR ',err)
	);
	
	
collection
	.next(res=>console.log(res))
	.error(err=>console.log(err));

collection.promisify

Promisify the responses

collection.promisify()

collection.unPromisify

Un promisify the responses. So normal returns are triggered on api calls

collection.unPromisify()

collection.getTheIndexOf

Get the index of an item by key/value

const response = collection.getTheIndexOf({id:1})

collection.list

List all the items in the collection instance

const response = collection.list()

collection.findWhere

Pluck an item by key/value

const response = collection.findWhere({id:1})

collection.exists

Return a Boolean true if the item is in the collection, or false if not

const response = collection.exists({id:1})

collection.insert

Insert an item at the end of the stack. Returns the collection after mutation.

const response = collection.insert({
    id: 3,
    name: 'Paki Paki'
})

collection.insertAtIndex

Splice in an item at a certain index. Returns the collection after mutation

const response = collection.insertAtIndex({
    id: 3,
    name: 'Paki Paki'
},index)

collection.upsert

Super handy upsert function. If the key/value is found then the data is updated, otherwise it's pushed into the stack. Returns the collection after mutation.

const response = collection.upsert({id:3},{
    id: 3,
    name: 'Paki Paki'
})

collection.updateWhere

Update an item where the key/value match an item in the collection. Returns the collection after mutation.

const response = collection.updateWhere({id:2},{
    id: 2,
    name: 'Mama Chiggy'
})

collection.removeWhere

Remove an item where the key/value matches an item in the collection. Returns the collection after mutation.

const response = collection.removeWhere({id:3})

Contributions

If you would like to contribute, find an issue, or have a feature request, create an Issue. Also, see CONTRIBUTORS.md for contribution instructions