{"_id":"cast","_rev":"12-f5df5322b0b04451f1d4d21b96d73c85","name":"cast","description":"Attempts to solve the problem of unintuitive data types","dist-tags":{"latest":"1.1.0"},"versions":{"0.1.0":{"author":{"name":"T. Jameson Little","email":"beatgammit@gmail.com"},"name":"cast","description":"Attempts to solve the problem of unintuitive data types","keywords":["cast","data-types","data types","types"],"version":"0.1.0","repository":{"type":"git","url":"git@github.com:beatgammit/cast.git"},"main":"lib/cast.js","engines":{"node":"~0.4"},"dependencies":{},"devDependencies":{},"_npmJsonOpts":{"file":"/home/otto/.npm/cast/0.1.0/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"cast@0.1.0","_engineSupported":true,"_npmVersion":"1.0.15","_nodeVersion":"v0.4.7","_defaultsLoaded":true,"dist":{"shasum":"15c117122b1c4826bef86ce7d2051c685f94b206","tarball":"https://registry.npmjs.org/cast/-/cast-0.1.0.tgz","integrity":"sha512-ZDNYdwpo9vODwznZchasOFVD+zO9DWpD33kOtBiNvWI3IyS1Df2PvarlE4zNqD18XrjODcl+pyU4JJV8m7ia9Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIELCnnriLZtzOHWj3KXhV8oUcoAkLNGC9K9g97nevq1KAiEA0eEmzDPkEznmXX15rylB3su23FLsrhSXk2TWhIr0O00="}]},"scripts":{},"maintainers":[{"name":"beatgammit","email":"t.jameson.little@gmail.com"}],"_npmUser":{"name":"beatgammit","email":"t.jameson.little@gmail.com"},"directories":{}},"1.0.0":{"author":{"name":"T. Jameson Little","email":"beatgammit@gmail.com"},"name":"cast","description":"Attempts to solve the problem of unintuitive data types","keywords":["cast","data-types","data types","types"],"version":"1.0.0","repository":{"type":"git","url":"git@github.com:beatgammit/cast.git"},"main":"lib/cast.js","engines":{"node":">= 0.4"},"dependencies":{},"devDependencies":{},"_npmUser":{"name":"beatgammit","email":"t.jameson.little@gmail.com"},"_id":"cast@1.0.0","_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.7","_defaultsLoaded":true,"dist":{"shasum":"fa13ca5bfa8593a7f126444f9dfbba97d8d8691f","tarball":"https://registry.npmjs.org/cast/-/cast-1.0.0.tgz","integrity":"sha512-geZApHJb0/P4CYPeONApoLqbBWttBy/U8K8JzHveKnDibxfuV+6hzLqa37CwihyztlApGQ7WZebLTDSPxPKryQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCSPXyyz6ANsIFAprSPlS/LlyuhOec8ovJxe0NY1nZrnAIhAOsM4CfW9PgjJErdBjVnhfAQA+XTs0bjJqhBinqpvtOd"}]},"maintainers":[{"name":"beatgammit","email":"t.jameson.little@gmail.com"}],"directories":{}},"1.0.1":{"author":{"name":"T. Jameson Little","email":"beatgammit@gmail.com"},"name":"cast","description":"Attempts to solve the problem of unintuitive data types","keywords":["cast","data-types","data types","types"],"version":"1.0.1","repository":{"type":"git","url":"git@github.com:beatgammit/cast.git"},"main":"lib/cast.js","engines":{"node":">= 0.4"},"dependencies":{},"devDependencies":{},"_npmUser":{"name":"beatgammit","email":"t.jameson.little@gmail.com"},"_id":"cast@1.0.1","_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.12","_defaultsLoaded":true,"dist":{"shasum":"43dbb731759087ef6a2f01e518e3b6d4f232f15e","tarball":"https://registry.npmjs.org/cast/-/cast-1.0.1.tgz","integrity":"sha512-i6R/MkMI2aK7PYZUWIKTQGgI5oPNQGWw/ss0os7579b1SQ2qO+STlP95AAxXIJmzvlvMCpH+qFZfADIdxS7zUg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAlGcQoBN17kSZq0gnhd4XpqJBIO647IwsHajR0iB/OxAiEA+rarpH89AGgaVlCC8bPo0MT37Y+YurO0dGN9KIVIgZE="}]},"maintainers":[{"name":"beatgammit","email":"t.jameson.little@gmail.com"}],"directories":{}},"1.1.0":{"author":{"name":"T. Jameson Little","email":"beatgammit@gmail.com"},"name":"cast","description":"Attempts to solve the problem of unintuitive data types","keywords":["cast","data-types","data types","types"],"version":"1.1.0","repository":{"type":"git","url":"git@github.com:beatgammit/cast.git"},"main":"lib/cast.js","engines":{"node":">= 0.4"},"dependencies":{},"devDependencies":{},"_npmUser":{"name":"beatgammit","email":"t.jameson.little@gmail.com"},"_id":"cast@1.1.0","optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.0-3","_nodeVersion":"v0.6.10","_defaultsLoaded":true,"dist":{"shasum":"a3320494b3f8c5c802f3c2f7960e14e4736dcc77","tarball":"https://registry.npmjs.org/cast/-/cast-1.1.0.tgz","integrity":"sha512-23ZULM+91htUUL3IrHjHDhdC9MrKpwgTXEgpB6X/fE/ikqesWu4K6K1vKdRJiI0zCs6vZc11C+eWFTOSJ5WFyw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAkyiBoKgWbJV5hO10XE9ngjef06eE6ZCudHRSX9d8g4AiEAr2SsZ0X3MrGEAI2axwlqATwrGaIGER8GaM8Y76PNB5A="}]},"readme":"TL;DR\n=====\n\n**Node**\n\n`npm install cast`\n\n**Ender**\n\n`ender add cast`\n\n**Usage**\n\n    var cast = require('cast');\n    \n    cast('false', 'boolean'); // will return the boolean false\n\nIntro\n=====\n\nTypes in JavaScript can be unpredictable, and trying to protect against the edge-cases is a headache. Consider the following:\n\n**Booleans**\n\n> true === \"true\" // makes sense\n> false !== \"false\" // ??\n> false === \"\" // ??\n> true === \"0\" // ?? or any string\n\n**Numbers**\n\n> isNaN(null) // false\n> isNaN(undefined) // true\n\nThere are many others, but these conditions make it very difficult to write truly high-level code. This module tries to solve this problem.\n\nThe main use case is simplification of form validation/user input. A single call to cast will eliminate the need to do extensive type-checking.\n\nUsage\n=====\n\n*function cast(val, type[, radix])*\n\n* val- the value to cast (strings are the most useful, but integers and arrays can also make sense)\n* type- string or function (anything else will throw an exception)\n    * if a function, an `instanceof` will be done internally\n    * if a string, acceptable values are: 'array', 'boolean', 'float', 'integer', 'number' (alias for 'float')\n* radix- only applies for integers\n\nThere are only two possible return values, `null` or something of the type specified by type. Since null cannot be assigned to (as undefined can), this makes complete sense. The first parameter is never modified, so this function truly does no evil.\n\nExamples\n--------\n\n**Arrays**\n\n> cast([], 'array'); // returns [] (same reference)\n> cast('[]', 'array'); // returns [] (from JSON.parse)\n\n**Booleans**\n\n> cast('true', 'boolean'); // returns true\n> cast('false', 'boolean'); // returns false\n> cast(true, 'boolean'); // returns true\n> cast(false, 'boolean'); // returns false\n\n**Integers**\n\n> cast('10', 'integer'); // returns 10\n> cast('10c', 'integer'); // returns null\n> cast('10e10', 'integer'); // returns null\n> cast(10, 'integer'); // returns 10\n> cast('10', 'integer', 8); // returns 8\n> cast('10', 'integer', '8'); // returns 8\n> cast('10.1', 'integer', 10); // returns null\n> cast('10.1', 'integer'); // returns null\n\n**Floats**\n\n> cast('5.25', 'float'); // returns 5.25\n\n**Strings**\n\n> cast(5, 'string'); // returns '5'\n> cast(true, 'string'; // returns 'true'\n> cast('hello', 'string'); // returns 'hello'\n> cast({}, 'string'); // returns null\n> cast(undefined, 'string'); // returns null\n> cast(null, 'string'); // returns null\n> cast([], 'string'); // returns null\n","maintainers":[{"name":"beatgammit","email":"t.jameson.little@gmail.com"}],"directories":{}}},"maintainers":[{"email":"amilajack@gmail.com","name":"amilajack"}],"time":{"modified":"2022-06-13T05:39:39.854Z","created":"2011-09-30T22:55:07.753Z","0.1.0":"2011-12-07T22:52:03.300Z","1.0.0":"2011-12-07T22:52:03.300Z","1.0.1":"2011-12-15T20:36:16.434Z","1.1.0":"2012-02-10T05:24:52.080Z"},"author":{"name":"T. Jameson Little","email":"beatgammit@gmail.com"},"repository":{"type":"git","url":"git@github.com:beatgammit/cast.git"}}