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

ko-genius

v0.0.2

Published

A library for getting resources and parsing them into an object graph, all using the Knockout API

Downloads

1

Readme

KO-Genius

Knockout makes it easy to bind view models to the DOM. But once you need to do extensive interaction with the server and pull down view models using AJAX, your work becomes tedious, complicated, and filled with boilerplate. KO-Genius helps circumvent all of that with callback-free view model definitions and instantiations. No mapping required. Automatic parsing.

And, unlike KnockBack, KO-Genius integrates with Knockout at its deepest levels, meaning smaller downloads and much greater efficiency. KO-Genius is just like [Genius] (http://geniusjs.com 'Genius'), but with a few useful additions that make working with KnockoutJS super easy.

To use KO-Genius, just include it on the page after Knockout. Then you're ready to start working.

Benefits

For starters, any Genius resource property created using a genius.types.* method will be a Knockout observable. For example, consider the following model definition:

var Zombie = genius.Resource.extend({
	name: genius.types.string(),
	id: genius.types.number(),
	age: genius.types.number(),
	url: "/zombies/:id"
});

var zombies = Zombie.$query();
ko.applyBindings({ myZombies: zombies });

Now use the following markup:

<img src="spinner.gif" data-bind="visible: myZombies.isLoading" />
<div data-bind="foreach: myZombies">
	<p>
		Name: 
		<span data-bind="text: name"></span>, 
		ID: 
		<span data-bind="text: id"></span>, 
		Age: 
		<span data-bind="text: age"></span>
	</p>
</div>

zombies will become an observable array, and Knockout will render a list of your zombies, all with their appropriate information. name, id, and age will all be knockout observables. What's more, Resource meta-properties, such as isLoading, isDirty, isDeleted, and isNew are all observable, so you're free to use them as you please in your Knockout bindings. In this example, the spinner will appear when the zombies request begins, and will disappear when the request returns.

Installation

You can install using Bower with bower install ko-genius and using NPM with npm install ko-genius. You can also just download ko-genius.js and add it manually to your project.

Tests

KO-Genius tests use Karma with Jasmine. To run the tests:

  • npm install -g karma
  • Inside the repository root: karma start

If you don't have Chrome installed, you can change the browser in karma.conf.js on line 59.

Contributing

Contributions are welcome. I'm not actively developing this project (I've moved on to another one that's more generic, vanilla JS), but I'll definitely try to fix your issues and review/merge any pull requests. I'm using GitHub flow, so you can PR directly into master.

I tell you this despite the danger of creating a crisis of choice: if you're using RequireJS, KO-Data might be a better option for you. The API is a lot more sensible, and it doesn't try to recreate the Dependency Injection wheel.