Comparing version 0.1.18 to 0.1.19
{ | ||
"name": "typa", | ||
"version": "0.1.18", | ||
"version": "0.1.19", | ||
"description": "A super-simple JavaScript type checker utility.", | ||
@@ -8,22 +8,16 @@ "main": "dist/typa.min.js", | ||
"test": "jest", | ||
"test-with-coverage": "jest --coverage && cat ./coverage/lcov.info | env-cmd ./.env codacy-coverage" | ||
"test-with-coverage": | ||
"jest --coverage && cat ./coverage/lcov.info | env-cmd ./.env codacy-coverage" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/selfagency/typa.git" | ||
"url": "git+https://bitbucket.com/selfagencyll/typa.git" | ||
}, | ||
"keywords": [ | ||
"javascript", | ||
"checker", | ||
"type", | ||
"typeof", | ||
"types", | ||
"utility" | ||
], | ||
"keywords": ["javascript", "checker", "type", "typeof", "types", "utility"], | ||
"author": "The Self Agency, LLC", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/selfagency/typa/issues" | ||
"url": "https://bitbucket.org/selfagencyllc/typa/issues" | ||
}, | ||
"homepage": "https://github.com/selfagency/typa#readme", | ||
"homepage": "https://bitbucket.org/selfagencyllc/typa", | ||
"devDependencies": { | ||
@@ -30,0 +24,0 @@ "codacy-coverage": "^2.1.0", |
@@ -1,9 +0,9 @@ | ||
Typa | ||
==== | ||
# Typa | ||
A super-simple JavaScript type checker. Mainly pilfered from [this blog post](https://www.webbjocke.com/javascript-check-data-types/) by [Webbjocke](https://github.com/webbjocke). No dependencies. 3.6K [GCC](https://github.com/google/closure-compiler-js) compiled, 2.0K uncompiled. | ||
[![Codacy grade](https://img.shields.io/codacy/grade/c14912365bf14b74a778862a50d72860.svg)](https://www.codacy.com/app/Self_Agency/typa?utm_source=github.com&utm_medium=referral&utm_content=selfagency/typa&utm_campaign=Badge_Grade) [![Codacy coverage](https://img.shields.io/codacy/coverage/c14912365bf14b74a778862a50d72860.svg)](https://www.codacy.com/app/Self_Agency/typa?utm_source=github.com&utm_medium=referral&utm_content=selfagency/typa&utm_campaign=Badge_Coverage) [![CircleCI](https://img.shields.io/circleci/project/github/selfagency/typa.svg)](https://circleci.com/gh/selfagency/typa) [![GitHub issues](https://img.shields.io/github/issues/selfagency/typa.svg)](https://github.com/selfagency/typa/issues) [![npm](https://img.shields.io/npm/dt/typa.svg)](https://www.npmjs.com/package/typa) [![npm](https://img.shields.io/npm/v/typa.svg)](https://www.npmjs.com/package/typa) | ||
[![Codacy grade](https://img.shields.io/codacy/grade/c14912365bf14b74a778862a50d72860.svg)](https://www.codacy.com/app/Self_Agency/typa?utm_source=github.com&utm_medium=referral&utm_content=selfagency/typa&utm_campaign=Badge_Grade) [![Codacy coverage](https://img.shields.io/codacy/coverage/c14912365bf14b74a778862a50d72860.svg)](https://www.codacy.com/app/Self_Agency/typa?utm_source=github.com&utm_medium=referral&utm_content=selfagency/typa&utm_campaign=Badge_Coverage) [![CircleCI](https://circleci.com/bb/selfagencyllc/typa/tree/master.svg?style=svg)](https://circleci.com/bb/selfagencyllc/typa/tree/master) ![Bitbucket issues](https://img.shields.io/bitbucket/issues/selfagencyllc/typa.svg) [![npm](https://img.shields.io/npm/dt/typa.svg)](https://www.npmjs.com/package/typa) [![npm](https://img.shields.io/npm/v/typa.svg)](https://www.npmjs.com/package/typa) | ||
**Install** | ||
``` | ||
@@ -14,4 +14,5 @@ npm install typa | ||
**Import** | ||
``` | ||
import {is} from 'typa' | ||
import is from 'typa' | ||
@@ -24,2 +25,3 @@ /* or */ | ||
**Quick Start** | ||
``` | ||
@@ -36,29 +38,29 @@ const hello = 'Hello!' | ||
API | ||
--- | ||
+ <a href="#array">*arr*</a> → Array | ||
+ <a href="#bad">*bad*</a> → Null, undefined, empty, or an error | ||
+ <a href="#boolean">*bool*</a> → Boolean | ||
+ <a href="#date">*date*</a> → Date | ||
+ <a href="#empty">*empty*</a> → Empty string, array, or object | ||
+ <a href="#error">*err*</a> → Error | ||
+ <a href="#function">*fn*</a> → Function | ||
+ <a href="#integer">*int*</a> → Integer | ||
+ <a href="#json">*json*</a> → Serialized JSON object | ||
+ <a href="#null">*nll*</a> → Null | ||
+ <a href="#noru">*noru*</a> → Null or undefined | ||
+ <a href="#number">*num*</a> → Number | ||
+ <a href="#object">*obj*</a> → Object | ||
+ <a href="#promise">*prom*</a> → Promise | ||
+ <a href="#regex">*regex*</a> → Regular expression | ||
+ <a href="#string">*str*</a> → String | ||
+ <a href="#symbol">*sym*</a> → Symbol | ||
+ <a href="#undefined">*undef*</a> → Undefined | ||
## API | ||
Typa Method | ||
----------- | ||
* <a href="#array">_arr_</a> → Array | ||
* <a href="#bad">_bad_</a> → Null, undefined, empty, or an error | ||
* <a href="#boolean">_bool_</a> → Boolean | ||
* <a href="#date">_date_</a> → Date | ||
* <a href="#empty">_empty_</a> → Empty string, array, or object | ||
* <a href="#error">_err_</a> → Error | ||
* <a href="#function">_fn_</a> → Function | ||
* <a href="#integer">_int_</a> → Integer | ||
* <a href="#json">_json_</a> → Serialized JSON object | ||
* <a href="#null">_nll_</a> → Null | ||
* <a href="#noru">_noru_</a> → Null or undefined | ||
* <a href="#number">_num_</a> → Number | ||
* <a href="#object">_obj_</a> → Object | ||
* <a href="#promise">_prom_</a> → Promise | ||
* <a href="#regex">_regex_</a> → Regular expression | ||
* <a href="#string">_str_</a> → String | ||
* <a href="#symbol">_sym_</a> → Symbol | ||
* <a href="#undefined">_undef_</a> → Undefined | ||
## Typa Method | ||
Ternary function that checks if the supplied value matches the specified type, then returns the first function (or value) if true or the second function (or value) if false. | ||
**.typa**($type, $value, $fn1, $fn2) | ||
``` | ||
@@ -78,6 +80,6 @@ const myString = 'this is a string' | ||
Individual Methods | ||
------------------ | ||
## Individual Methods | ||
<a name="array"></a>**.arr**($value) — Array | ||
``` | ||
@@ -89,2 +91,3 @@ const isArray = is.arr(['text', 12]) | ||
<a name="bad"></a>**.bad**($value) — Null, undefined, empty, or an error | ||
``` | ||
@@ -105,2 +108,3 @@ let isBad = is.bad(null) | ||
<a name="boolean"></a>**.bool**($value) — Boolean | ||
``` | ||
@@ -115,2 +119,3 @@ let isBool = is.bool(true) | ||
<a name="date"></a>**.date**($value) — Date | ||
``` | ||
@@ -122,2 +127,3 @@ const isDate = is.date(new Date()) | ||
<a name="empty"></a>**.empty**($value) — Empty string, array, or object | ||
``` | ||
@@ -135,2 +141,3 @@ let isEmpty = is.empty('') | ||
<a name="error"></a>**.err**($value) — Error | ||
``` | ||
@@ -142,2 +149,3 @@ const isErr = is.err(new Error('This is an error.')) | ||
<a name="function"></a>**.fn**($value) — Function | ||
``` | ||
@@ -149,2 +157,3 @@ const isFn = is.fn(() => { console.log('Hi!') }) | ||
<a name="integer"></a>**.int**($value) — Integer | ||
``` | ||
@@ -156,2 +165,3 @@ const isInt = is.int(12) | ||
<a name="json"></a>**.json**($value) — Serialized JSON object | ||
``` | ||
@@ -163,2 +173,3 @@ const isJson = is.json('{"key": "value"}') | ||
<a name="null"></a>**.nll**($value) — Null | ||
``` | ||
@@ -170,2 +181,3 @@ const isNll = is.nll(null) | ||
<a name="noru"></a>**.noru**($value) — Null or Undefined | ||
``` | ||
@@ -180,2 +192,3 @@ let isNoru = is.noru(null) | ||
<a name="number"></a>**.num**($value) — Number | ||
``` | ||
@@ -187,2 +200,3 @@ const isNum = is.num(28.2) | ||
<a name="object"></a>**.obj**($value) — Object | ||
``` | ||
@@ -194,2 +208,3 @@ const isObj = is.obj({ key: 'value' }) | ||
<a name="promise"></a>**.prom**($value) — Promise | ||
``` | ||
@@ -210,2 +225,3 @@ const myPromise = new Promise((resolve, reject) => { | ||
<a name="regex"></a>**.regex**($value) — Regular Expression | ||
``` | ||
@@ -217,2 +233,3 @@ const isRegex = is.regex(new Regex(/\W/)) | ||
<a name="string"></a>**.str**($value) — String | ||
``` | ||
@@ -224,2 +241,3 @@ const isStr = is.str('text') | ||
<a name="symbol"></a>**.sym**($value) — Symbol | ||
``` | ||
@@ -231,2 +249,3 @@ const isSym = is.sym(Symbol(42)) | ||
<a name="undefined"></a>**.undef**($value) — Undefined | ||
``` | ||
@@ -233,0 +252,0 @@ const isUndef = is.undef(undefined) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
154559
234
1
2