{"id":20963853,"url":"https://github.com/codemix/casting","last_synced_at":"2025-05-14T09:31:46.195Z","repository":{"id":17657294,"uuid":"20461879","full_name":"codemix/casting","owner":"codemix","description":"Tiny type casting library for node.js and the browser.","archived":false,"fork":false,"pushed_at":"2014-11-30T20:03:49.000Z","size":156,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-02T00:47:47.935Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codemix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-03T22:21:38.000Z","updated_at":"2016-03-21T21:02:53.000Z","dependencies_parsed_at":"2022-09-04T01:22:09.214Z","dependency_job_id":null,"html_url":"https://github.com/codemix/casting","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemix%2Fcasting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemix%2Fcasting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemix%2Fcasting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemix%2Fcasting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codemix","download_url":"https://codeload.github.com/codemix/casting/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225284588,"owners_count":17449931,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T02:48:37.432Z","updated_at":"2024-11-19T02:48:38.101Z","avatar_url":"https://github.com/codemix.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Casting\n\n[![Build Status](https://travis-ci.org/codemix/casting.svg?branch=master)](https://travis-ci.org/codemix/casting)\n\nTiny type casting library for node.js and the browser.\n\n# Installation\n\nVia [npm](https://npmjs.org/package/casting):\n\n    npm install --save casting\n\n\nor [bower](http://bower.io/search/?q=casting):\n\n\n    bower install --save casting\n\n\n# Usage\n\n```js\nvar casting = require('casting');\n\ncasting.cast(Array, 123); // [123]\ncasting.cast(String, 123); // '123'\ncasting.cast(Date, '2014-01-01'); // [object Date]\n\nfunction MyType (value) {\n  this.name = value.name;\n  this.isActive = value.isActive;\n}\n\ncasting.define('mytype', MyType);\n\ncasting.cast('mytype', {name: 'name', isActive: true}); // [object MyType]\n\nvar castAll = casting.forDescriptors({\n  name: {\n    type: 'string'\n  },\n  isActive: {\n    type: Boolean\n  }\n});\n\nvar user = {name: 123, isActive: 0};\n\nconsole.log(castAll(user)); // {name: '123', isActive: false}\n\n\n```\n\n\n# Running the tests\n\nFirst, `npm install`, then `npm test`. Code coverage generated with `npm run coverage`.\n\n\n# License\n\nMIT, see [LICENSE.md](LICENSE.md).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemix%2Fcasting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodemix%2Fcasting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemix%2Fcasting/lists"}