diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9a019e3 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Miraris + +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. diff --git a/README.md b/README.md index f54731b..0b6029d 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,14 @@ # Node AniDB wrapper -[![npm](https://img.shields.io/npm/dm/anidbjs.svg?style=flat-square)](https://www.npmjs.com/package/anidbjs) -[![Build Status](https://travis-ci.org/miraris/anidbjs.svg?branch=master)](https://travis-ci.org/miraris/anidbjs) +[![Build Status][travis-svg]][travis-url] +[![dependency status][deps-svg]][deps-url] +[![dev dependency status][dev-deps-svg]][dev-deps-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][npm-badge-png]][package-url] + +> A minimalistic AniDB HTTP API wrapper for Node.js. This module provides a very minimal interface to fetch data from anidb.net. You may want to read the guidelines in the anidb [wiki](http://wiki.anidb.net/w/HTTP_API_Definition) first. @@ -25,3 +32,16 @@ client .then(res => console.log(res)) .catch(err => console.error(err)); ``` + +[package-url]: https://npmjs.org/package/anidbjs +[travis-svg]: https://travis-ci.org/miraris/anidbjs.svg +[travis-url]: https://travis-ci.org/miraris/anidbjs +[deps-svg]: https://david-dm.org/miraris/anidbjs.svg +[deps-url]: https://david-dm.org/miraris/anidbjs +[dev-deps-svg]: https://david-dm.org/miraris/anidbjs/dev-status.svg +[dev-deps-url]: https://david-dm.org/miraris/anidbjs#info=devDependencies +[npm-badge-png]: https://nodei.co/npm/anidbjs.png +[license-image]: http://img.shields.io/npm/l/anidbjs.svg +[license-url]: LICENSE +[downloads-image]: http://img.shields.io/npm/dm/anidbjs.svg +[downloads-url]: http://npm-stat.com/charts.html?package=anidbjs \ No newline at end of file diff --git a/lib/utils/index.js b/lib/utils/index.js index 3ceddd9..e0d2a86 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -1,9 +1,3 @@ -/** - * Check whether a value is undefined or empty - * @param {*} val - */ -const isNull = val => typeof val === 'undefined' || val == null - /** * Ensure the value is an array * @param {*} arr @@ -14,28 +8,19 @@ const ensureArray = arr => (Array.isArray(arr) ? arr : [arr]) * Try to parse an integer * @param {*} number */ -const tryParseInt = number => { - if (isNull(number)) return - return parseInt(number, 10) -} +const tryParseInt = number => (number ? parseInt(number, 10) : undefined) /** * Try to parse a float * @param {*} number */ -const tryParseFloat = number => { - if (isNull(number)) return - return parseFloat(number, 10) -} +const tryParseFloat = number => (number ? parseFloat(number, 10) : undefined) /** * Try to parse a boolean * @param {*} bool */ -const tryParseBool = bool => { - if (isNull(bool)) return - return bool === 'true' -} +const tryParseBool = bool => bool === 'true' module.exports = { ensureArray,