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

prototypeof

v1.0.0

Published

šŸ‘Œ Simply get the type of an object.

Downloads

4

Readme

prototypeof Build Status

šŸ‘Œ Simply get the type of an object.

prototypeof is a simple function to get the type of an object by using Object.prototype.toString on any given object. Usually, this is always the best way to guess the type of an object since typeof may return things not expected (Array and Null are considered object).

Furthermore, even when using Object.prototype.toString, thereā€™s no easy way to make custom types names. Thatā€™s why I created prototypeof.

The name may look misleading (weā€™re not actually getting the prototype), but is etymologically correct. Which corresponds to Ļ€ĻĻ‰Ļ„Īæ- (prōto-) (most recent ancestor) and type.

Getting Started

const prototypeof = require('prototypeof');

class Type {
    constructor() {
    }
}

var type = new Type();
console.log(prototypeof(type)); // "Object"
console.log(prototypeof(Type, 'Type')); // "Type"
console.log(prototypeof(type)); // "Type"

JavaScript API

prototypeof ( object[, type])

Get the type of an object and optionally set its type. If the object has a prototype, set the prototypal type. Finally return the type name.

  • object: Any objects or primitives.
  • type: Optional. If truthy, set the type name.
  • Return: A type name as a String.

License

This module and the whole directory is subject to the MIT license.

I usually prefer the GPL license, but I donā€™t think itā€™s big enough care for that (and scare people like you).

Copyright (c) 2017 Etienne Prudā€™homme