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 🙏

© 2026 – Pkg Stats / Ryan Hefner

rubyjs

v0.7.2

Published

JavaScript standard library (String, Array, etc) based on Ruby core-lib.

Downloads

10

Readme

RubyJS

RubyJS is a port of the Ruby core-lib and provides many methods for Array, String, Numerics and more. RubyJS classes are simple wrappers around native JavaScript objects.

See RubyJS Homepage for more details. It is licensed under MIT.

Contribute/Develop

RubyJS is currently implemented in CoffeeScript 1.3.3. CoffeeScript 1.4.0 doesn't work as of now. It's on the roadmap to move away from CoffeeScript to plain JS.

  • Clone repository
  • Run the coffee console loading the rubyjs files:
/path/to/rubyjs $ coffee -r ./ruby.coffee
coffee> R('hello world').capitalize()
"Hello World"
coffee> R('hello world').capitalize().toNative()
'Hello world'
  • Setup development environment:
$ bundle install
$ cake build_tests            # compiles all test files
$ bundle exec guard           # automatically compile coffeescript
$ rake jasmine                # starts jasmine server
$ open http://localhost:8888  # pray

If you get the error: pipe(): Too many open files, see following page:

https://github.com/jashkenas/coffee-script/issues/1537

For Mac OS X users the following comment helps:

https://github.com/joyent/node/issues/2479#issuecomment-7082186

API Docs

You can quickly search and jump through the documentation by using the fuzzy finder dialog:

Open fuzzy finder dialog: Ctrl-T

In frame mode you can toggle the list naviation frame on the left side:

Toggle list view: Ctrl-L

You can focus a list in frame mode or toggle a tab in frameless mode:

  • Class list: Ctrl-C
  • Method list: Ctrl-M
  • Extras list: Ctrl-E

You can focus and blur the search input:

  • Focus search input: `Ctrl-S
  • Blur search input: Esc
  • In frameless mode you can close the list tab: Esc

Namespace

RubyJS is the official namespace of all classes and mixins. R is an alias to RubyJS. In the documentation both versions are used interchangeably.

RubyJS('foo')
RubyJS.String
RubyJS.Array
// Equivalent to:
R('foo')
R.String
R.Array

R additionaly includes R.Kernel, so methods defined there can be used with R.

R.puts('hello world')

String

RubyJS.String wraps a native String primitive.

R('foo')
new R.String('foo')
R.String.new('foo')
R.$String(1) // Emulates Ruby String(1)

Destructive methods have a _bang suffix.

str = R('foo')
str.capitalize()      //=> 'Foo'
str                   //=> 'foo'
str.capitalize_bang() //=> 'Foo'
str                   //=> 'Foo'

Create multiple R.Strings with R.w equivalent to Ruby %w[].

words = R.w('foo bar baz')

Array

Arrays are ordered, integer-indexed collections of any object. Array indexing starts at 0, as in C or Java. A negative index is assumed to be relative to the end of the array—that is, an index of -1 indicates the last element of the array, -2 is the next to last element in the array, and so on.

RubyJS.Array wraps a native JavaScript array. Members are not directly accessible using [] notation, use RubyJS.Array.get(1) and set(1, 'foo') instead.

Array includes optimized versions of RubyJS.Enumerable methods.

 R([1,2,3])           // => an R.Array of Number primitives
 R([1,2,3], true)     // => an R.Array of R.Fixnums
 new R.Array([1,2,3])

Enumerable, Enumerator

The Enumerable mixin provides collection classes with several traversal and searching methods, and with the ability to sort. The class must provide a method each, which yields successive members of the collection. If Enumerable#max, #min, or #sort is used, the objects in the collection must also implement a meaningful <=> operator, as these methods rely on an ordering between members of the collection.

Enumerable is currently included in Array, Range and Enumerator. Array implements optimized versions of the methods.

Numerics

Numeric and Integer are both modules. Functional number types are Fixnum (an Integer) and Float.

  • Fixnum includes Numeric, Integer
  • Float includes Numeric

Mathematic operations like +, -, * with RubyJS numerics is expensive as for every operation extra objects are created. It is suggested to use JavaScript native primitives for calculations, especially in loops.

Aliases

Where Ruby methods conflict with JavaScript naming the following aliases are used. You can also use the old names through property the brackets, e.g. ['=='].

str.equals('foo')
str['==']('foo')

# '?' is removed
include    : include?

# '!'' => _bang
upcase_bang: upcase!

append     : <<
equals     : ==
equal_case : ===
cmp        : <=>
lt         : <
lteq       : <=
gt         : >
gteq       : >=
modulo     : %
plus       : +
minus      : -
multiply   : *
exp        : **
divide     : /

# Typecasting:

R.$String(): String()
R.$Float() : Float()

# Special variables

R['$~']    : $~
R['$;']    : $;
R['$,']    : $,