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

orcorum

v0.1.10

Published

Helper library for JavaScript

Downloads

25

Readme

orcorum NPM Version

Helper library for JavaScript

Installing

npm install orcorum

Running the tests

npm test

API

orcorum.classes

extend(properties[, statics])

To create a class of your own base class, you extend your base class and provide instance properties, as well as optional statics to be attached directly to the constructor function.

function Animal(name) {
    this.name = name;
}

Animal.prototype.getName = function() {
    return this.name;
};

Animal.extend = orcorum.classes.extend;

// ...

var Dog = Animal.extend({
    bark: function() {
        return 'GUAUUU!!!'
    }
});

var dog = new Dog('pepito');

console.log(dog.name); // => pepito

console.log(dog.bark()); // => GUAUUU!!!

orcorum.object

get(target, keys[, defaultValue])

Get property of target.

orcorum.object.get({
    name: 'pepito',
    age: 3
}, 'age'); // => 3

orcorum.object.get({
    name: {
        first: 'pepito',
        last: 'roman'
    },
    age: 3
}, ['name', 'first']); // => pepito

orcorum.object.get({
    name: {
        first: 'pepito',
        last: 'roman'
    },
    age: 3
}, ['name', 'alias'], 'pepe'); // => pepe

orcorum.object.get({
    name: {
        first: 'pepito',
        last: 'roman'
    },
    age: 3
}, ['works', 'first', 'beginDate']); // => undefined

set(target, keys, value)

Set property in target.

orcorum.object.set({
    name: 'pepito',
    age: 3
}, 'name', 'josecito'); // => {name: 'josecito', age: 3}

orcorum.object.set({
    name: {
        first: 'pepito',
        last: 'roman'
    },
    age: 3
}, ['name', 'first'], 'josecito'); // => {name: {first: 'josecito', last: 'roman'}, age: 3}

orcorum.object.set({
    name: {
        first: 'pepito',
        last: 'roman'
    },
    age: 3
}, ['name', 'alias'], 'pepe'); // => {name: {first: 'pepito', last: 'roman', alias: 'pepe'}, age: 3}

extend(target, *sources)

Override properties of target with the all properties in the source objects (in-order), and return the target object.

orcorum.object.extend({
    name: 'pepito',
    age: 3
}, {
    age: 4
}); // => {name: 'pepito', age: 4}

orcorum.object.extend({
    name: {
        first: 'pepito',
        last: 'roman'
    },
    age: 3
}, {
    name: {
        last: 'robin'
    }
}); // => {name: {first: 'pepito', last: 'robin'}, age: 3}

orcorum.url

normalize(url)

Normalize url path.

console.log(orcorum.url.normalize('')); // => Client size '' - Server side '/'
console.log(orcorum.url.normalize('/path/to')); // => /path/to
console.log(orcorum.url.normalize('/path/to/')); // => /path/to
console.log(orcorum.url.normalize('http://www.mysite.com')); // => http://www.mysite.com

params(url, key, value)

Add or return url params.

console.log(orcorum.url.params('')); // => {}
console.log(orcorum.url.params('/path/to?search=auto')); // => {search: 'auto'}
console.log(orcorum.url.params('/path/to?search=auto&country=ar', 'country')); // => ar
console.log(orcorum.url.params('/path/to?search=auto&country=ar', 'country', 'en')); // => /path/to?search=auto&country=en
console.log(orcorum.url.params('/path/to', {
    search: 'auto',
    country: 'ar'
})); // => /path/to?search=auto&country=ar

removeParams(url, key)

Remove url params.

console.log(orcorum.url.removeParams('/path/to?search=auto&country=ar', 'country')); // => /path/to?search=auto
console.log(orcorum.url.removeParams('/path/to?search=auto', 'search')); // => /path/to

cleanParams(url)

Remove all url params.

console.log(orcorum.url.cleanParams('/path/to?search=auto&country=ar')); // => /path/to
console.log(orcorum.url.cleanParams('/path/to?search=auto')); // => /path/to

orcorum.time

SECONDS, MINUTE, HOUR, DAY, MONTH and YEAR

Time in milliseconds.

console.log(orcorum.time.SECOND); // => 1000
console.log(orcorum.time.MINUTE); // => 60000
console.log(orcorum.time.HOUR);   // => 3600000
console.log(orcorum.time.DAY);    // => 86400000
console.log(orcorum.time.MONTH);  // => 2592000000
console.log(orcorum.time.YEAR);   // => 31104000000

orcorum.http

method, status and type

Time in milliseconds.

console.log(orcorum.http.method.GET); // => 'get'
console.log(orcorum.http.method.POST); // => 'post'
// ...
console.log(orcorum.http.status.OK); // => 200
console.log(orcorum.http.status.SUCCESS); // => 200
console.log(orcorum.http.status.NO_CONTENT); // => 204
// ...
console.log(orcorum.http.type.FORM);   // => 'application/x-www-form-urlencoded'
console.log(orcorum.http.type.MULTIPART);   // => 'multipart/form-data'
// ...

orcorum.fs

requiredirSync(dirname[, options])

Requires all files in a directory into an object with the same structure.

Options
  • excludes Files excludes. Defaults to ['index'].
  • extension Files extension. Only require the file match with this extension. Defaults to '.js'].
orcorum.fs.requiredirSync(__dirname);

// Or 
orcorum.fs.requiredirSync(__dirname, {
    excludes: ['my_exclude_file']
});

// Or 
orcorum.fs.requiredirSync(__dirname, {
    extension: '.json'
});