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

cldr-plurals-runtime-js

v1.2.0

Published

Javascript runtime for CLDR plural rules generated by camertron/cldr-plurals.

Downloads

5

Readme

cldr-plurals-runtime-js

Build Status

Javascript runtime methods for CLDR plural rules (see camertron/cldr-plurals).

Installation

gem install cldr-plurals-runtime-js

Usage

const runtime = require('cldr-plurals-runtime');

Functionality

The CLDR data set contains plural information for numerous languages in an expression-based format defined by Unicode's TR35. The document describes how to determine the various parts of a number and how to use those parts to determine the plural rule. The parts as they appear in TR35 are:

| Symbol | Value | |:-------|----------------------------------------------------------------| | n | absolute value of the source number (integer and decimals). | | i | integer digits of n. | | v | number of visible fraction digits in n, with trailing zeros. | | w | number of visible fraction digits in n, without trailing zeros.| | f | visible fractional digits in n, with trailing zeros. | | t | visible fractional digits in n, without trailing zeros. |

cldr-plurals-runtime-js is an implementation of these calculations in Javascript. Rules can be compiled into Javascript using the cldr-plurals rubygem:

require 'cldr-plurals'

rules = CldrPlurals::Compiler::RuleList.new(:ru).tap do |rule_list|
  rule_list.add_rule(:one, 'v = 0 and i % 10 = 1 and i % 100 != 11')
  rule_list.add_rule(:few, 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14')
  rule_list.add_rule(:many, 'v = 0 and i % 10 = 0 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 11..14')
end

js_code = rules.to_code(:javascript)

Once you've produced the Javascript code for the rule list, you can execute them like so:

const runtime = require('cldr-plurals-runtime');
const rule = function() { ... }  // code generated above by cldr-plurals
console.log(rule('3', runtime))  // => "few"

Requirements

No external requirements.

Running Tests

jasmine-node spec/ should do the trick.

Authors

  • Cameron C. Dutro: http://github.com/camertron