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

ember-car

v0.0.4

Published

Lisp-like `car` and `cdr` helpers for Ember

Downloads

2

Readme

ember-car Build Status

ember-car is an ember-cli addon that provides Lisp-like car and cdr helpers.

The short version is that given a list (array), car returns the item at the head of the list (index 0), while cdr returns a list (array) without the first element.

Usage

Installation

ember install ember-car

In Your Application

Two template helpers are provided, called car and cdr. These are automatically resolved so you can just use them in your templates without any additional code.

These template helpers each take a single (positional) parameter, the list on which to operate. car returns a scalar value (or null, if the given array is empty); cdr returns an array (which may be empty).

Here's a brief partial example of their use:

// app/routes/index.js
import Ember from 'ember';

export default Ember.Route.extend({
  model() {
    return [ 'first', 'second', 'third' ];
  }
});
{{!-- app/templates/index.hbs --}}
car(model): {{car model}}
<br>
cdr(model): {{cdr model}}
<br>
car(cdr(model)): {{car (cdr model)}}

This example will render the output:

car(model): first
cdr(model): second,third
car(cdr(model)): second

Notes

These helpers are designed to be used with arrays, but also to not blow up when used with non-arrays (primitives or objects). If car is passed a non-array value, it simply returns it. If cdr is passed a non-array value, it returns an empty array. Effectively, non-array parameters are treated as if they were arrays that contained only the given value.

Why?!

This addon was created mainly as a jokey response to what feels to me like the increasing Lisp-ification of templates. You are welcome, however, to find actual uses for this.