Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

type-name

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

type-name - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

23

build/type-name.js

@@ -1,3 +0,16 @@

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.typeName = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
/**
* Modules in this bundle
* @license
*
* type-name:
* license: MIT
* author: Takuto Wada <takuto.wada@gmail.com>
* contributors: azu, Yosuke Furukawa
* homepage: https://github.com/twada/type-name
* version: 2.0.0
*
* This header is generated by licensify (https://github.com/twada/licensify)
*/
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.typeName = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw (f.code="MODULE_NOT_FOUND", f)}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
/**
* type-name - Just a reasonable typeof

@@ -7,5 +20,5 @@ *

*
* Copyright (c) 2014-2015 Takuto Wada
* Copyright (c) 2014-2016 Takuto Wada
* Licensed under the MIT license.
* http://twada.mit-license.org/2014-2015
* http://twada.mit-license.org/2014-2016
*/

@@ -22,3 +35,3 @@ 'use strict';

var strName = toStr.call(obj).slice(8, -1);
if (strName === 'Object' && obj.constructor) {
if ((strName === 'Object' || strName === 'Error') && obj.constructor) {
return funcName(obj.constructor);

@@ -44,2 +57,2 @@ }

},{}]},{},[1])(1)
});
});

@@ -0,1 +1,26 @@

## [2.0.0](https://github.com/twada/type-name/releases/tag/v2.0.0) (2016-01-06)
#### Features
* [return the actual Error constructor name](https://github.com/twada/type-name/pull/5), closes [#4](https://github.com/twada/type-name/issues/4)
#### Breaking Changes
* `typeName(error)` returns actual error constructor name, not just `'Error'` ([c857cea3](https://github.com/twada/type-name/commit/c857cea3d79523105f3aa14552df8bd3267a88cb))
before:
```js
typeName(new TypeError('type error!')) // => 'Error'
```
after 2.0.0:
```js
typeName(new TypeError('type error!')) // => 'TypeError'
```
* component is no longer supported ([e6f17109](https://github.com/twada/type-name/commit/e6f17109b6aece2e6f535d2918794fd9094628f8))
## [1.1.0](https://github.com/twada/type-name/releases/tag/v1.1.0) (2015-10-18)

@@ -2,0 +27,0 @@

@@ -6,5 +6,5 @@ /**

*
* Copyright (c) 2014-2015 Takuto Wada
* Copyright (c) 2014-2016 Takuto Wada
* Licensed under the MIT license.
* http://twada.mit-license.org/2014-2015
* http://twada.mit-license.org/2014-2016
*/

@@ -21,3 +21,3 @@ 'use strict';

var strName = toStr.call(obj).slice(8, -1);
if (strName === 'Object' && obj.constructor) {
if ((strName === 'Object' || strName === 'Error') && obj.constructor) {
return funcName(obj.constructor);

@@ -24,0 +24,0 @@ }

{
"name": "type-name",
"description": "Just a reasonable typeof",
"version": "1.1.0",
"version": "2.0.0",
"author": {

@@ -22,4 +22,10 @@ "name": "Takuto Wada",

"devDependencies": {
"browserify": "^12.0.1",
"derequire": "^2.0.3",
"dereserve": "^0.1.1",
"jshint": "^2.8.0",
"mocha": "^2.3.3"
"licensify": "^2.0.1",
"mocha": "^2.3.3",
"woothee": "^1.3.0",
"zuul": "^3.8.0"
},

@@ -39,4 +45,4 @@ "directories": {

"keywords": [
"typeof",
"type"
"type",
"typeof"
],

@@ -50,20 +56,9 @@ "license": "MIT",

"scripts": {
"build": "browserify index.js --standalone typeName | derequire > ./build/type-name.js",
"build": "mkdir -p build && browserify index.js --plugin licensify --standalone typeName | dereserve | derequire > ./build/type-name.js",
"lint": "jshint index.js",
"test": "npm run lint && mocha"
},
"testling": {
"files": "test/*.js",
"browsers": [
"ie/6..latest",
"chrome/22..latest",
"firefox/16..latest",
"safari/latest",
"opera/11.0..latest",
"iphone/6..latest",
"ipad/6..latest",
"android-browser/latest"
],
"harness": "mocha"
"preversion": "npm test",
"test": "npm run lint && mocha",
"test-saucelabs": "zuul -- test/*.js",
"version": "npm run build && git add -A build"
}
}

@@ -6,8 +6,8 @@ type-name

[![Build Status](https://travis-ci.org/twada/type-name.svg?branch=master)](https://travis-ci.org/twada/type-name)
[![NPM version](https://badge.fury.io/js/type-name.svg)](http://badge.fury.io/js/type-name)
[![Dependency Status](https://gemnasium.com/twada/type-name.svg)](https://gemnasium.com/twada/type-name)
[![License](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://twada.mit-license.org/2014-2015)
[![Build Status][travis-image]][travis-url]
[![NPM version][npm-image]][npm-url]
[![Dependency Status][depstat-image]][depstat-url]
[![License][license-image]][license-url]
[![browser support](https://ci.testling.com/twada/type-name.png)](https://ci.testling.com/twada/type-name)
[![Sauce Test Status][saucelabs-image]][saucelabs-url]

@@ -25,3 +25,3 @@

| boolean literal | `false` | `'boolean'` |
| regexp literal | `/^not/` | `'RegExp'` |
| regexp literal *(Android 4.1+)* | `/^not/` | `'RegExp'` |
| array literal | `['foo', 4]` | `'Array'` |

@@ -34,3 +34,3 @@ | object literal | `{name: 'bar'}` | `'Object'` *(be careful!)* |

| Date object | `new Date()` | `'Date'` |
| RegExp object | `new RegExp('^not', 'g')` | `'RegExp'` |
| RegExp object *(Android 4.1+)* | `new RegExp('^not', 'g')` | `'RegExp'` |
| Array object | `new Array()` | `'Array'` |

@@ -40,2 +40,3 @@ | Object object | `new Object()` | `'Object'` |

| Error object | `new Error('error!')` | `'Error'` |
| TypeError object | `new TypeError('type error!')` | `'TypeError'` |
| NaN | `NaN` | `'number'` |

@@ -75,2 +76,3 @@ | Infinity | `Infinity` | `'number'` |

assert(typeName(new Error('error!')) === 'Error');
assert(typeName(new TypeError('type error!')) === 'TypeError');
assert(typeName(NaN) === 'number');

@@ -138,15 +140,6 @@ assert(typeName(Infinity) === 'number');

### via component
Install and build
$ component install twada/type-name
$ component build
Then use as usual.
AUTHOR
---------------------------------------
* [Takuto Wada](http://github.com/twada)
* [Takuto Wada](https://github.com/twada)

@@ -162,2 +155,18 @@

---------------------------------------
Licensed under the [MIT](http://twada.mit-license.org/2014-2015) license.
Licensed under the [MIT](https://twada.mit-license.org/2014-2016) license.
[npm-url]: https://npmjs.org/package/type-name
[npm-image]: https://badge.fury.io/js/type-name.svg
[travis-url]: https://travis-ci.org/twada/type-name
[travis-image]: https://secure.travis-ci.org/twada/type-name.svg?branch=master
[depstat-url]: https://gemnasium.com/twada/type-name
[depstat-image]: https://gemnasium.com/twada/type-name.svg
[license-url]: https://twada.mit-license.org/2014-2016
[license-image]: https://img.shields.io/badge/license-MIT-brightgreen.svg
[saucelabs-url]: https://saucelabs.com/u/type-name
[saucelabs-image]: https://saucelabs.com/browser-matrix/type-name.svg

@@ -12,2 +12,3 @@ function Person(name, age) {

var typeName = require('..'),
woothee = require('woothee'),
assert = require('assert'),

@@ -32,2 +33,3 @@ fixtures = {

'TypeError object': new TypeError('type error!'),
'RangeError object': new RangeError('range error!'),
'user-defined constructor': new Person('alice', 5),

@@ -42,6 +44,30 @@ 'anonymous constructor': new AnonPerson('bob', 4),

if (typeof JSON !== 'undefined') {
function addJsonSuite (tests, fixtures) {
if (typeof JSON === 'undefined') {
return;
}
fixtures['JSON'] = JSON;
if (typeof navigator !== 'undefined' && navigator.userAgent) {
var ua = woothee.parse(navigator.userAgent);
if (ua.name === 'Internet Explorer' && (ua.version === '6.0' || ua.version === '7.0')) {
tests.push(['JSON', 'Object']);
return;
}
}
tests.push(['JSON', 'JSON']);
}
function tweakRegExpSuite (tests) {
if (typeof navigator !== 'undefined' && navigator.userAgent) {
var ua = woothee.parse(navigator.userAgent);
if (ua.os === 'Android' && ua.version === '4.0') {
tests.push(['regexp literal', 'function']);
tests.push(['RegExp object', 'function']);
return;
}
}
tests.push(['regexp literal', 'RegExp']);
tests.push(['RegExp object', 'RegExp']);
}
describe('typeName of', function () {

@@ -52,3 +78,2 @@ var i, tests = [

['boolean literal', 'boolean'],
['regexp literal', 'RegExp'],
['array literal', 'Array'],

@@ -61,3 +86,2 @@ ['object literal', 'Object'], // be careful!

['Date object', 'Date'],
['RegExp object', 'RegExp'],
['Array object', 'Array'],

@@ -67,3 +91,4 @@ ['Object object', 'Object'],

['Error object', 'Error'],
['TypeError object', 'Error'],
['TypeError object', 'TypeError'],
['RangeError object', 'RangeError'],
['NaN', 'number'],

@@ -77,5 +102,4 @@ ['Infinity', 'number'],

];
if (typeof JSON !== 'undefined') {
tests.push(['JSON', 'JSON']);
}
addJsonSuite(tests, fixtures);
tweakRegExpSuite(tests);

@@ -82,0 +106,0 @@ for(i = 0; i < tests.length; i += 1) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc