You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

github-username-regex

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github-username-regex

A regular expression that only matches a valid Github username

0.0.0
Source
npmnpm
Version published
Weekly downloads
6.6K
-27.51%
Maintainers
1
Weekly downloads
 
Created
Source

append-type

NPM version Bower version Build Status Coverage Status devDependencies Status

Stringify the value with appending its type: 10'10 (number)'

import appendType from 'append-type';

appendType('123'); //=> '123 (string)'
appendType(123); //=> '123 (number)'

Installation

npm

npm install append-type

bower

bower install append-type

API

appendType(value)

value: any type
Return: String

Essentially, it returns String(value) + ' (' + typeof value + ')'.

appendType(() => {}); //=> '() => {} (function)'

When it takes null / undefined, it returns 'null' / 'undefined'.

appendType(null); //=> 'null'
appendType(undefined); //=> 'undefined'

Example

This module is useful for making TypeError error messages.

function reverse(v) {
  if (typeof v !== 'boolean') {
    throw new TypeError(`Expected a Boolean value, but got ${appendType(v)}.`);
  }

  return !v;
};

reverse(1); //=> TypeError: Expected a Boolean value, but got 1 (number).

License

Copyright (c) 2016 Shinnosuke Watanabe

Licensed under the MIT License.

Keywords

github

FAQs

Package last updated on 17 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts