feature(util) Util.type -> itype

This commit is contained in:
coderaiser 2016-12-28 17:26:30 +02:00
parent fc058fcfa7
commit f35585b3ac
21 changed files with 332 additions and 100 deletions

View file

@ -27,7 +27,6 @@
"commit": "be9ab0b0f7b8e685da89321df384ac902fa3c587"
},
"_source": "https://github.com/coderaiser/currify.git",
"_target": "^2.0.3",
"_originalSource": "currify",
"_direct": true
"_target": "2.0.3",
"_originalSource": "currify"
}

35
modules/itype/.bower.json Normal file
View file

@ -0,0 +1,35 @@
{
"name": "itype",
"description": "Improved type check",
"main": "dist/itype.js",
"authors": [
"coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)"
],
"license": "MIT",
"keywords": [
"type",
"string",
"array",
"object",
"boolean",
"null",
"undefined",
"check"
],
"homepage": "https://github.com/coderaiser/itype",
"ignore": [
".*",
"test",
"lib"
],
"version": "2.0.3",
"_release": "2.0.3",
"_resolution": {
"type": "version",
"tag": "v2.0.3",
"commit": "ec7f35bfdc6f9078d4e4792dd347bf98dd2f8ccc"
},
"_source": "https://github.com/coderaiser/itype.git",
"_target": "2.0.3",
"_originalSource": "itype"
}

35
modules/itype/ChangeLog Normal file
View file

@ -0,0 +1,35 @@
2016.12.28, v2.0.3
fix:
- (bower) main
2016.12.28, v2.0.2
feature:
- (bower) ignore: add ".*"
2016.12.28, v2.0.1
feature:
- (bower) add
2016.12.28, v2.0.0
feature:
- (itype) add browser support
2015.01.30, v1.0.2
feature:
- (type) change format of regexp
2014.12.22, v1.0.1
feature:
- (itype) add null

21
modules/itype/LICENSE Normal file
View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 coderaiser
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

52
modules/itype/README.md Normal file
View file

@ -0,0 +1,52 @@
# iType [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
Improved type check.
## Install
```
npm i itype --save
```
## How to use?
```js
var itype = require('itype');
console.og(itype.string('hello'))
// returns
true
console.log(itype('world'));
// returns
'string'
console.log(itype.array([1, 2]));
// returns
true
```
## Environments
In old `node.js` environments that not fully supports `es2015`, `itype` could be used with:
```js
var itype = require('itype/legacy');
```
## License
MIT
[NPMIMGURL]: https://img.shields.io/npm/v/itype.svg?style=flat
[BuildStatusIMGURL]: https://img.shields.io/travis/coderaiser/itype/master.svg?style=flat
[DependencyStatusIMGURL]: https://img.shields.io/gemnasium/coderaiser/itype.svg?style=flat
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
[NPMURL]: https://npmjs.org/package/itype "npm"
[BuildStatusURL]: https://travis-ci.org/coderaiser/itype "Build Status"
[DependencyStatusURL]: https://gemnasium.com/coderaiser/itype "Dependency Status"
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
[CoverageURL]: https://coveralls.io/github/coderaiser/itype?branch=master
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/itype/badge.svg?branch=master&service=github

25
modules/itype/bower.json Normal file
View file

@ -0,0 +1,25 @@
{
"name": "itype",
"description": "Improved type check",
"main": "dist/itype.js",
"authors": [
"coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)"
],
"license": "MIT",
"keywords": [
"type",
"string",
"array",
"object",
"boolean",
"null",
"undefined",
"check"
],
"homepage": "https://github.com/coderaiser/itype",
"ignore": [
".*",
"test",
"lib"
]
}

49
modules/itype/dist/itype.js vendored Normal file
View file

@ -0,0 +1,49 @@
(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.itype = 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})({"itype":[function(require,module,exports){
'use strict';
module.exports = new TypeProto();
function TypeProto() {
/**
* get type of variable
*
* @param variable
*/
function type(variable) {
var regExp = /\s([a-zA-Z]+)/;
var str = {}.toString.call(variable);
var typeBig = str.match(regExp)[1];
var result = typeBig.toLowerCase();
return result;
}
/**
* functions check is variable is type of name
*
* @param variable
*/
function typeOf(name, variable) {
return type(variable) === name;
}
function typeOfSimple(name, variable) {
return typeof variable === name;
}
['arrayBuffer', 'file', 'array', 'object']
.forEach(function (name) {
type[name] = typeOf.bind(null, name);
});
['null', 'string', 'undefined', 'boolean', 'number', 'function']
.forEach(function (name) {
type[name] = typeOfSimple.bind(null, name);
});
return type;
}
},{}]},{},["itype"])("itype")
});

1
modules/itype/dist/itype.min.js vendored Normal file
View file

@ -0,0 +1 @@
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.itype=e()}}(function(){return function e(n,r,t){function o(i,u){if(!r[i]){if(!n[i]){var c="function"==typeof require&&require;if(!u&&c)return c(i,!0);if(f)return f(i,!0);var l=new Error("Cannot find module '"+i+"'");throw l.code="MODULE_NOT_FOUND",l}var a=r[i]={exports:{}};n[i][0].call(a.exports,function(e){var r=n[i][1][e];return o(r?r:e)},a,a.exports,e,n,r,t)}return r[i].exports}for(var f="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}({itype:[function(e,n,r){"use strict";function t(){function e(e){var n=/\s([a-zA-Z]+)/,r={}.toString.call(e),t=r.match(n)[1],o=t.toLowerCase();return o}function n(n,r){return e(r)===n}function r(e,n){return typeof n===e}return["arrayBuffer","file","array","object"].forEach(function(r){e[r]=n.bind(null,r)}),["null","string","undefined","boolean","number","function"].forEach(function(n){e[n]=r.bind(null,n)}),e}n.exports=new t},{}]},{},["itype"])("itype")});

View file

@ -0,0 +1,53 @@
{
"name": "itype",
"version": "2.0.3",
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
"description": "Improved type check",
"main": "lib/itype.js",
"repository": {
"type": "git",
"url": "git://github.com/coderaiser/itype.git"
},
"keywords": [
"type",
"string",
"array",
"object",
"boolean",
"null",
"undefined",
"check"
],
"scripts": {
"test": "tape test/*.js",
"watcher": "nodemon -w test -w lib --exec",
"watch:test": "npm run watcher -- npm test",
"watch:coverage": "npm run watcher -- npm run coverage",
"lint": "eslint lib test",
"build": "redrun clean init 6to5 legacy:* bundle minify",
"init": "mkdirp dist legacy",
"minify": "minify dist/itype.js > dist/itype.min.js",
"wisdom": "npm run build",
"clean": "rimraf legacy dist",
"bundle:base": "browserify -s itype --ng false",
"bundle": "npm run bundle:base -- -r ./legacy/lib/itype.js:itype ./legacy/lib/itype.js -o dist/itype.js",
"coverage": "nyc npm test",
"report": "nyc report --reporter=text-lcov | coveralls",
"6to5": "buble lib -o legacy/lib",
"legacy:index": "echo \"module.exports = require('./lib/itype');\" > legacy/index.js"
},
"dependencies": {},
"license": "MIT",
"devDependencies": {
"browserify": "^13.0.0",
"buble": "^0.15.1",
"coveralls": "^2.11.9",
"eslint": "^3.10.2",
"minify": "^2.0.5",
"mkdirp": "^0.5.1",
"nodemon": "^1.11.0",
"nyc": "^10.0.0",
"redrun": "^5.0.1",
"tape": "^4.5.1"
}
}