{"_id":"torf","_rev":"11-fdb8acbb056c80ae2e8273a383d32db3","name":"torf","description":"Small utility for checking if variables are defined and non empty","dist-tags":{"latest":"1.0.7"},"versions":{"1.0.0":{"name":"torf","version":"1.0.0","description":"Small utility for checking if variables are defined and non empty","main":"index.js","scripts":{"test":"istanbul test ./node_modules/.bin/_mocha -- --recursive -R dot"},"author":{"name":"Besart Hoxhaj, William Fisher"},"license":"MIT","devDependencies":{"chai":"^2.2.0","istanbul":"^0.3.13","mocha":"^2.2.4"},"dependencies":{"is-number":"^1.1.2"},"gitHead":"aa0a56b7226d1032d23bdb4dc876ca30a4565670","_id":"torf@1.0.0","_shasum":"11c86d8f3707396efaadee4c9843153b6e7f732f","_from":".","_npmVersion":"2.1.17","_nodeVersion":"0.10.33","_npmUser":{"name":"bes","email":"besartshyti@gmail.com"},"dist":{"shasum":"11c86d8f3707396efaadee4c9843153b6e7f732f","tarball":"https://registry.npmjs.org/torf/-/torf-1.0.0.tgz","integrity":"sha512-VdBwN1aT/Iye4QMNorGItkJ2faEmWx+1JQf3kuTp+rVLEBdSYD6gSoVTNFB6FfacJBtQtZq3xvHdrmKv8s6DLA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFYWZ0q40Bm7+SQO+dtDm07T16bEuhf/01a6pACDEzS3AiAgo4bx9zgl4wzOvIuDyMMwx+wFJ5QuNQjSeIN7r1VsSQ=="}]},"maintainers":[{"name":"bes","email":"besartshyti@gmail.com"}]},"1.0.1":{"name":"torf","version":"1.0.1","description":"Small utility for checking if variables are defined and non empty","main":"index.js","scripts":{"test":"istanbul test ./node_modules/.bin/_mocha -- --recursive -R dot"},"repository":{"type":"git","url":"https://github.com/besarthoxhaj/torf"},"author":{"name":"Besart Hoxhaj, William Fisher"},"license":"MIT","devDependencies":{"chai":"^2.2.0","istanbul":"^0.3.13","mocha":"^2.2.4"},"dependencies":{"is-number":"^1.1.2"},"gitHead":"09a7cd0634d797fbd492132f4c63f0576392a19f","bugs":{"url":"https://github.com/besarthoxhaj/torf/issues"},"homepage":"https://github.com/besarthoxhaj/torf","_id":"torf@1.0.1","_shasum":"77de6c860a6c29b4d2b37b5bc48d2bfba345606a","_from":".","_npmVersion":"2.1.17","_nodeVersion":"0.10.33","_npmUser":{"name":"bes","email":"besartshyti@gmail.com"},"dist":{"shasum":"77de6c860a6c29b4d2b37b5bc48d2bfba345606a","tarball":"https://registry.npmjs.org/torf/-/torf-1.0.1.tgz","integrity":"sha512-oRfKPkZu6YOyz+u8uU9cNBEoPQUM4FdHOmUqcXPgkrGHaWZN4L+FfNXrbA7/eS8/6KaBJLNtNT4W2WgYW7cZmw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCONBBddZJLcyV8TK/DrBVSnYXHOFavufttPDvqruUaGgIgOD3kkIaohlc/5N6OlEMtwzx9Pz9dVt3NzsjYPDWaj+0="}]},"maintainers":[{"name":"bes","email":"besartshyti@gmail.com"},{"name":"filwisher","email":"williamfisher@hotmail.co.uk"}]},"1.0.2":{"name":"torf","version":"1.0.2","description":"Small utility for checking if variables are defined and non empty","main":"index.js","scripts":{"test":"istanbul test ./node_modules/.bin/_mocha -- --recursive -R dot"},"repository":{"type":"git","url":"https://github.com/besarthoxhaj/torf"},"author":{"name":"Besart Hoxhaj, William Fisher"},"license":"MIT","devDependencies":{"chai":"^2.2.0","istanbul":"^0.3.13","mocha":"^2.2.4"},"dependencies":{"is-number":"^1.1.2"},"gitHead":"60114550c4041c7e8ca351474615347a766b1ec9","bugs":{"url":"https://github.com/besarthoxhaj/torf/issues"},"homepage":"https://github.com/besarthoxhaj/torf","_id":"torf@1.0.2","_shasum":"869c29ddd08dde899961839d6b20fa116617a564","_from":".","_npmVersion":"2.1.17","_nodeVersion":"0.10.33","_npmUser":{"name":"bes","email":"besartshyti@gmail.com"},"dist":{"shasum":"869c29ddd08dde899961839d6b20fa116617a564","tarball":"https://registry.npmjs.org/torf/-/torf-1.0.2.tgz","integrity":"sha512-/bEDBn6aoSR522TwNqAi6HH2iHdWXlNjxkdrR4UbLSpv1hItbSvXp2whJ5GvAnZ5hse9VOybBZ+lzBgPho4t0g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDbtD2JjjblRPdfLfoDuwlG8/htTe84kL5j2Bq39Edz8gIhAJ+cLjtRhswFTBGflNy66QCbPfdTCkb1mfyfAC91M1J+"}]},"maintainers":[{"name":"bes","email":"besartshyti@gmail.com"},{"name":"filwisher","email":"williamfisher@hotmail.co.uk"}]},"1.0.3":{"name":"torf","version":"1.0.3","description":"Small utility for checking if variables are defined and non empty","main":"index.js","scripts":{"test":"istanbul test ./node_modules/.bin/_mocha -- --recursive -R dot"},"repository":{"type":"git","url":"https://github.com/besarthoxhaj/torf"},"author":{"name":"Besart Hoxhaj, William Fisher"},"license":"MIT","devDependencies":{"chai":"^2.2.0","istanbul":"^0.3.13","mocha":"^2.2.4"},"dependencies":{"is-number":"^1.1.2"},"gitHead":"b0c78ee34f856738d8119bfa5981a323889f8534","bugs":{"url":"https://github.com/besarthoxhaj/torf/issues"},"homepage":"https://github.com/besarthoxhaj/torf","_id":"torf@1.0.3","_shasum":"ef43558ba39bceea39bf5df243fbe269312f7364","_from":".","_npmVersion":"2.1.17","_nodeVersion":"0.10.33","_npmUser":{"name":"bes","email":"besartshyti@gmail.com"},"dist":{"shasum":"ef43558ba39bceea39bf5df243fbe269312f7364","tarball":"https://registry.npmjs.org/torf/-/torf-1.0.3.tgz","integrity":"sha512-yc2jzNOfnJY45SKtC+pmRI37ULUNa7s0NkqxkHSmomEiEhyqipciDYVZEmMrhUSSxpY1qCP1PTniqzKPMRqPIg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCzkRlXoTx8DOeK25XETROQy6YZBFsXazJX3UlqttJ04QIhAKO7CMXKG7wI4eZa4C3KQ+Sjr0qhB1wbN6n8DvzWS7NW"}]},"maintainers":[{"name":"bes","email":"besartshyti@gmail.com"},{"name":"filwisher","email":"williamfisher@hotmail.co.uk"}]},"1.0.4":{"name":"torf","version":"1.0.4","description":"Small utility for checking if variables are defined and non empty","main":"index.js","scripts":{"test":"_mocha","jshint":"jshint -c ./.jshintrc --exclude-path .gitignore .","coverage":"istanbul cover ./node_modules/.bin/_mocha && istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100"},"pre-commit":["jshint","coverage"],"repository":{"type":"git","url":"https://github.com/besarthoxhaj/torf"},"author":{"name":"Besart Hoxhaj, William Fisher"},"license":"MIT","devDependencies":{"chai":"^2.2.0","istanbul":"^0.3.13","jshint":"^2.7.0","mocha":"^2.2.4","pre-commit":"^1.0.6"},"dependencies":{"is-number":"^1.1.2"},"gitHead":"2af511a8df82584e0f0e6e7e4b8f2b493d9bef7d","bugs":{"url":"https://github.com/besarthoxhaj/torf/issues"},"homepage":"https://github.com/besarthoxhaj/torf","_id":"torf@1.0.4","_shasum":"59672195c43a3839b442dd93a57c15b5805b75bd","_from":".","_npmVersion":"2.1.17","_nodeVersion":"0.10.33","_npmUser":{"name":"bes","email":"besartshyti@gmail.com"},"dist":{"shasum":"59672195c43a3839b442dd93a57c15b5805b75bd","tarball":"https://registry.npmjs.org/torf/-/torf-1.0.4.tgz","integrity":"sha512-eEgX9KcR77u+vrUlW9oNh5KpLdOQYgRxlfBrpOs1Gj/sk++x0ileFgCpFPsiMOX2fReCrRzur3LI/J44X0bdGw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIB2gHD7fuUTs255rbjN/sCueownyXEkkOwQr/rfGd63sAiAwdltaph8gljdev3zVTEsOIQMbZb1hdvX7w1+6W+j/uQ=="}]},"maintainers":[{"name":"bes","email":"besartshyti@gmail.com"},{"name":"filwisher","email":"williamfisher@hotmail.co.uk"}]},"1.0.5":{"name":"torf","version":"1.0.5","description":"Small utility for checking if variables are defined and non empty","main":"index.js","scripts":{"test":"_mocha","jshint":"jshint -c ./.jshintrc --exclude-path .gitignore .","coverage":"istanbul cover ./node_modules/.bin/_mocha && istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100"},"pre-commit":["jshint","coverage"],"repository":{"type":"git","url":"https://github.com/besarthoxhaj/torf"},"author":{"name":"Besart Hoxhaj, William Fisher"},"license":"MIT","devDependencies":{"chai":"^2.2.0","istanbul":"^0.3.13","jshint":"^2.7.0","mocha":"^2.2.4","pre-commit":"^1.0.6"},"dependencies":{"is-number":"^1.1.2"},"gitHead":"5fa21bc6e6ceed08e4cfa3cc1092bb955ff5052a","bugs":{"url":"https://github.com/besarthoxhaj/torf/issues"},"homepage":"https://github.com/besarthoxhaj/torf","_id":"torf@1.0.5","_shasum":"b68257470c0c5e26d50fffc4c0b812caa3c563d1","_from":".","_npmVersion":"2.1.17","_nodeVersion":"0.10.33","_npmUser":{"name":"bes","email":"besartshyti@gmail.com"},"dist":{"shasum":"b68257470c0c5e26d50fffc4c0b812caa3c563d1","tarball":"https://registry.npmjs.org/torf/-/torf-1.0.5.tgz","integrity":"sha512-oCTqgn2UNdpuB2wlqBG0HWpKzXH9bc03fviSMMKR8SzguprMdEdK2KUrPYIuXXe/LlKWdfsAgKJ2kwcV+qIy2g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF0TFTqdrnZm70TALutKMOHmd7UovG+pgqd4eNzOeJe8AiAZlfuef/mryQ9s4ab0szNXzRXbiZ6Y3d+qVvfaU3sX0w=="}]},"maintainers":[{"name":"bes","email":"besartshyti@gmail.com"},{"name":"filwisher","email":"williamfisher@hotmail.co.uk"}]},"1.0.6":{"name":"torf","version":"1.0.6","description":"Small utility for checking if variables are defined and non empty","main":"index.js","scripts":{"test":"_mocha","jshint":"jshint -c ./.jshintrc --exclude-path .gitignore .","coverage":"istanbul cover ./node_modules/.bin/_mocha && istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100"},"pre-commit":["jshint","coverage"],"repository":{"type":"git","url":"https://github.com/besarthoxhaj/torf"},"author":{"name":"Besart Hoxhaj, William Fisher"},"license":"MIT","devDependencies":{"chai":"^2.2.0","istanbul":"^0.3.13","jshint":"^2.7.0","mocha":"^2.2.4","pre-commit":"^1.0.6"},"gitHead":"ac7fc999feb49951b81de7ac0c1889eae25cf64e","bugs":{"url":"https://github.com/besarthoxhaj/torf/issues"},"homepage":"https://github.com/besarthoxhaj/torf","_id":"torf@1.0.6","_shasum":"113992a24a4e35c2439afb437bc1ef8be6d8ff5e","_from":".","_npmVersion":"2.1.17","_nodeVersion":"0.10.33","_npmUser":{"name":"bes","email":"besartshyti@gmail.com"},"dist":{"shasum":"113992a24a4e35c2439afb437bc1ef8be6d8ff5e","tarball":"https://registry.npmjs.org/torf/-/torf-1.0.6.tgz","integrity":"sha512-jk2s75MsUY2m+5rz+LJgzswQtnhu7eZFrIIZYnjsHPUOdxbIvBbY3LZiD7NLfJN12WKTEvJaiN7bNeI+43gNOQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDo1EiMNKmdlUg6CWnUYBAwWdx5OhN7kJ2rkgkLqU+SIAIgZdMmf5f306nr/4Lfgflhq0zPQcDKV6EFdVOEHCD+PN8="}]},"maintainers":[{"name":"bes","email":"besartshyti@gmail.com"},{"name":"filwisher","email":"williamfisher@hotmail.co.uk"}]},"1.0.7":{"name":"torf","version":"1.0.7","description":"Small utility for checking if variables are defined and non empty","main":"index.js","scripts":{"test":"_mocha","jshint":"jshint -c ./.jshintrc --exclude-path .gitignore .","coverage":"istanbul cover ./node_modules/.bin/_mocha && istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100"},"pre-commit":["jshint","coverage"],"repository":{"type":"git","url":"https://github.com/besarthoxhaj/torf"},"author":{"name":"Besart Hoxhaj, William Fisher"},"license":"MIT","devDependencies":{"chai":"^2.2.0","istanbul":"^0.3.13","jshint":"^2.7.0","mocha":"^2.2.4","pre-commit":"^1.0.6"},"gitHead":"190691217dcf8187dade944243ef10e7766c435c","bugs":{"url":"https://github.com/besarthoxhaj/torf/issues"},"homepage":"https://github.com/besarthoxhaj/torf","_id":"torf@1.0.7","_shasum":"f559e2ae62fd4f80f83d00439fee8c910460fc53","_from":".","_npmVersion":"2.1.17","_nodeVersion":"0.10.33","_npmUser":{"name":"bes","email":"besartshyti@gmail.com"},"dist":{"shasum":"f559e2ae62fd4f80f83d00439fee8c910460fc53","tarball":"https://registry.npmjs.org/torf/-/torf-1.0.7.tgz","integrity":"sha512-SmF2FZdCllgPzxepaip9knDh+MV4QCZVI1br1+D1JzatfrYcDho5C/im9VvNKXqg8P2CZLaJCrTv0yLcVdpmvg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAWzN9v13I98JTzANZeBEC5+kykdMlG8QMymbiN84fzuAiB1T/nQlP+MM5Vyo+3rnEI1y06S6QLCN7Kgf/lh987Meg=="}]},"maintainers":[{"name":"bes","email":"besartshyti@gmail.com"},{"name":"filwisher","email":"williamfisher@hotmail.co.uk"}]}},"readme":"# torf\n\n[![Build Status](https://travis-ci.org/besarthoxhaj/torf.svg?branch=master)](https://travis-ci.org/besarthoxhaj/torf) \n[![Code Climate](https://codeclimate.com/github/besarthoxhaj/torf/badges/gpa.svg)](https://codeclimate.com/github/besarthoxhaj/torf) \n[![Test Coverage](https://codeclimate.com/github/besarthoxhaj/torf/badges/coverage.svg)](https://codeclimate.com/github/besarthoxhaj/torf) \n[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/besarthoxhaj/torf/issues)\n\n\nSmall library for cheking if a variable is ***ok***.\n\n\tnpm install torf --save\n\nFor readability I suggest to save the module in a variable called `is`.\n\n##is.ok();\n\nThis method simply checks if a variable is ***ok*** in general terms. ***Is ok*** means that a variable is defined and in case it is an object (or array) that it is not empty or the content is not undifined or null. \n\n```js\nvar is = require('torf');\n\nis.ok([]);            // false\nis.ok({});            // false\nis.ok([{}]);          // false\nis.ok(NaN);           // false\nis.ok(null);          // false\nis.ok(Infinity);      // false\nis.ok(undefined);     // false\nis.ok([NaN]);         // false\nis.ok([null]);        // false\nis.ok([Infinity]);    // false\nis.ok([undefined]);   // false\n```\n\nYou can pass functions as well. In that case the function will be invoked and the test will be performed on what the function returns.\n\n```js\nis.ok(function(){});                    // false\nis.ok(function(){return NaN;});         // false\nis.ok(function(){return false;});       // false\nis.ok(function(){return null;});        // false\nis.ok(function(){return Infinity;});    // false\nis.ok(function(){return undefined;});   // false\nis.ok(function(){return [undefined];}); // false\n```\n\nThis is done recursively, which means it is possible to nest functions.\n\n```js\nis.ok(function(){ return function(){ return false;}}); // false\nis.ok(function(){ return function(){ return true;}});  // true\n```\n\n\n##is.type();\n\nThis method simply checks the first argument class or primitive value against the second argument.\n\n```js\nvar is = require('torf');\n\nis.type('string', 'string'); // true\nis.type(['fooo'], 'array');  // true\nis.type({a:'hi'}, 'string'); // false\n```\n\nIt is possible to pass an array of classes as second argument, in which case it will return true if one of the classes is matched.\n\n```js\nvar is = require('torf');\n\nis.type('string', ['string', 'number', 'object']); // true\nis.type(['fooo'], ['null', 'array', 'date']);      // true\nis.type({a:'hi'}, ['string', 'number', 'array']);  // false\n```\n\n\nThe comparison is done by calling the `Object.prototype.toString()` to detect object class so it's possible\nto test alse `undefined === null`.\n\n```js\nis.type(undefined, 'null');  // false\nis.type(null, 'null');       // true\n```\n\n\n##is.email();\n\nInternally it uses a regular expression `/\\S+@\\S+\\.\\S+/` which is pretty ***generous***. If you need more restriction I suggest to look at the second example.\n\n```js\nvar is = require('torf');\n\nis.email('foo@bar.com');      // true;\nis.email('foo.zoo@bar.com');  // true;\nis.email('foo.zoo@bar');      // false;\nis.email(null);               // false;\nis.email(undefined);          // false;\n\n```\n\nOptionally you can pass a regular expression to check against as second parameter.\n\n```js\nvar is = require('torf');\n\nis.email('foo@bar.com', new RegExp(/[\\s\\S]/));  // true\n\n```","maintainers":[{"name":"bes","email":"besartshyti@gmail.com"},{"name":"filwisher","email":"williamfisher@hotmail.co.uk"}],"time":{"modified":"2022-06-27T18:46:20.202Z","created":"2015-04-19T09:47:45.555Z","1.0.0":"2015-04-19T09:47:45.555Z","1.0.1":"2015-04-19T09:51:29.044Z","1.0.2":"2015-04-19T09:55:40.903Z","1.0.3":"2015-04-19T22:06:22.386Z","1.0.4":"2015-04-25T20:26:31.578Z","1.0.5":"2015-04-25T20:34:06.336Z","1.0.6":"2015-04-25T20:37:03.583Z","1.0.7":"2015-05-26T20:26:23.531Z"},"author":{"name":"Besart Hoxhaj, William Fisher"},"license":"MIT","readmeFilename":"README.md","homepage":"https://github.com/besarthoxhaj/torf","repository":{"type":"git","url":"https://github.com/besarthoxhaj/torf"},"bugs":{"url":"https://github.com/besarthoxhaj/torf/issues"}}