{"id":13455122,"url":"https://github.com/SkyHacks/nerds","last_synced_at":"2025-03-24T07:32:22.407Z","repository":{"id":57309968,"uuid":"63409427","full_name":"SkyHacks/nerds","owner":"SkyHacks","description":"The API after every nerd's heart...","archived":false,"fork":false,"pushed_at":"2024-06-10T07:50:55.000Z","size":35,"stargazers_count":111,"open_issues_count":1,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-02T09:48:41.220Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SkyHacks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-15T09:23:31.000Z","updated_at":"2025-02-18T03:49:07.000Z","dependencies_parsed_at":"2022-09-05T12:41:03.278Z","dependency_job_id":null,"html_url":"https://github.com/SkyHacks/nerds","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SkyHacks%2Fnerds","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SkyHacks%2Fnerds/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SkyHacks%2Fnerds/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SkyHacks%2Fnerds/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SkyHacks","download_url":"https://codeload.github.com/SkyHacks/nerds/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245227566,"owners_count":20580898,"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-07-31T08:01:01.502Z","updated_at":"2025-03-24T07:32:22.115Z","avatar_url":"https://github.com/SkyHacks.png","language":"JavaScript","readme":"![nerdsJS Logo](https://cloud.githubusercontent.com/assets/10717361/16980893/6926284c-4e25-11e6-8447-da4e9adc3003.png)\n\n[![Coverage Status](https://coveralls.io/repos/github/SkyHacks/nerds/badge.svg?branch=master)](https://coveralls.io/github/SkyHacks/nerds?branch=master)\n![Open Source Love](https://badges.frapsoft.com/os/v2/open-source.svg?v=103)\n[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php)\n[![Awesome](https://camo.githubusercontent.com/13c4e50d88df7178ae1882a203ed57b641674f94/68747470733a2f2f63646e2e7261776769742e636f6d2f73696e647265736f726875732f617765736f6d652f643733303566333864323966656437386661383536353265336136336531353464643865383832392f6d656469612f62616467652e737667)](https://github.com/sindresorhus/awesome-nodejs)\n\n## The API after every nerd's heart...\n\nnerdsJS is an API for easily generating random data from your favorite nerdy movies, tv shows, and hobbies. Pull mock data into your app or presentation from Pokemon, Harry Potter, Star Wars and more (very soon). Effortlessly compose nerdy datasets by chaining methods in succint and intelligible expressions.\n\nReturn the datasets in whatever form works best for you. You can get it as a simple Array, wrapped in a Promise, or even get a Generator back.\n\n## Installation\n[![NPM](https://nodei.co/npm/nerds.png?downloads=true)](https://nodei.co/npm/nerds/)\n\nnerdsJS is available on npm. Navigate to your project's folder and run:\n```\nnpm install nerds\n```\nor download [the source code directly from Github](https://github.com/SkyHacks/nerds)\n\n## Quick Examples\n```javascript\nlet nerds = require('nerds');\n\nlet singleHP = nerds.resolve('Harry Potter').asArray();\nconsole.log(singleHP);\n/*\n[{\n\t'first': 'Hermione',\n\t'last': 'Granger',\n\t'full': 'Hermione Granger',\n\t'blood_status': 'Muggle-Born',\n\t'birthday': '19 September, 1979',\n\t'gender': 'Female',\n\t'house': 'Gryffindor',\n\t'wand': '10¾\", Vine Wood - Dragon Heartstring'\n}]\n*/\n\nlet multiPoke = nerds.resolve('Pokemon', 3).include(['name', 'type', 'hp']).asArray();\nconsole.log(multiPoke);\n/*\n[\n\t{'name':'Bulbasaur', 'type': 'Grass Poison', 'hp': 45},\n\t{'name':'Charmander', 'type': 'Fire', 'hp': 39},\n\t{'name':'Squirtle', 'type': 'Water', 'hp': 44}\n]\n*/\n\nlet genSW = nerds.resolve('Star Wars', 3).include(['name']).asGenerator();\ngenSW.next().value; // {\"name\":\"Luke Skywalker\"}\ngenSW.next().value; // {\"name\":\"Nute Gunray\"}\ngenSW.next().value; // {\"name\":\"Leia Organa\"}\ngenSW.next().value; // undefined\n```\n\n## Methods\n\nnerdsJS exposes an API that lets you chain methods together to get the exact fields and number of results you want. It is designed to be highly discoverable. Where possible, empty setters return valid options as examples. Every method comes standard with type and sanity checks and, if necessary, returns informative error messages.\n\n---\n\n### `resolve([topic], [results])`\n\nParameter | Type | Description\n---|---|---\ntopic|String|The topic that the data is based off of.\nresults|Number|Max number of results that will be returned.\n\nSets the topic and the max number of results to be returned (optionally). If no topic is assigned, returns all valid topics. If the number of results is not specified, nerds returns one random result by default. nerdsJS retrieves random data up to either the `results` or the size of the collection.\n\n```javascript\nnerds.resolve('Harry Potter');  //sets topic and returns the nerd context\n\nnerds.resolve('Harry Potter', 3);  //sets topic, number of results and returns the nerd context\n\nlet topics = nerds.resolve();\nconsole.log(topics);  //['Harry Potter','Star Wars','Pokemon']\n```\n\nWhen used as a setter, `resolve` returns the `nerds` context, meaning you can (and should) continue chaining subsequent methods.\n\n---\n\n### `fields()`\n\nConvenience getter method for discovering available fields. Topic must be set first. Returns array of all valid fields for the topic.\n\n```javascript\nlet fields = nerds.resolve('Pokemon').fields();\nconsole.log(fields);\n/*[\n\t'national_pokedex_number',\n\t'name',\n\t'type',\n\t'height',\n\t'weight',\n\t'total',\n\t'hp',\n\t'attack',\n\t'defense',\n\t'special_attack',\n\t'special_defense',\n\t'speed',\n\t'base_experience',\n\t'evolves_from'\n]*/\n```\n\n---\n\n### `include(fields)`\n\nParameter | Type | Description\n---|---|---\nfields|Array of Strings|The fields to include in the results.\n\nSets the fields to be included in the results. Accepts an array of strings. Any field not specified will not be included in the results. Topic must be set first.\n\n```javascript\nnerds.resolve('Star Wars').include(['name', 'homeworld'])  //sets fields and returns the nerd context\n```\n\n`include` returns the `nerds` context, meaning you can (and should) continue chaining subsequent methods.\n\n---\n\n### `exclude(fields)`\n\nParameter | Type | Description\n---|---|---\nfields|Array of Strings|The fields to exclude from the results.\n\nSets the fields to be excluded in the results. Accepts an array of strings. Any field not specified will be included in the results. Topic must be set first.\n\n```javascript\nnerds.resolve('Star Wars').exclude(['birth_year', 'eye_color'])  //sets fields and returns the nerd context\n```\n`exclude` returns the `nerds` context, meaning you can (and should) continue chaining subsequent methods.\n\n---\n\n#### *Once I've set the topic and fields, how to do I get the data?*\n\nAny of the following `as` methods will resolve the `nerd` method chain. This is what tells nerdsJS what format you would like to receive the data in.\n\n### `asArray()`\n\nReturns the dataset as a plain ol' JavaScript Array. The Array will contain data objects representing the search results (characters, Pokemon, etc).\n\n```javascript\nlet result = nerds.resolve('Harry Potter').asArray();\nconsole.log(result);\n/*\n[{\n\t'first':'Albus',\n\t'last': 'Dumbledore',\n\t'full': 'Albus Dumbledore',\n\t'blood_status': 'Half-Blood',\n\t'birthday': 'Summer 1881',\n\t'gender': 'Male',\n\t'house': 'Gryffindor',\n\t'wand': '15\", Elder - Thestral Tail Hair'\n}]\n*/\n```\n\n---\n\n### `asPromise()`\n\nReturns the same kind of result as `asArray()` except wrapped in a Promise. Once the promise is resolved, the resulting Array will contain data objects representing the search results (characters, Pokemon, etc).\n\n```javascript\nlet promise = nerds.resolve('Harry Potter').asPromise();\npromise.then(function (result) {\n\tconsole.log(result);\n/*\n[{\n\t'first': 'Neville',\n\t'last': 'Longbottom',\n\t'full': 'Neville Longbottom',\n\t'blood_status': 'Pure-Blood',\n\t'birthday': '30 July, 1980',\n\t'gender': 'Male',\n\t'house': 'Gryffindor',\n\t'wand': '13\", Cherry - Unicorn Hair'\n}]\n*/\n});\n```\n\n---\n\n### `asGenerator()`\n\nReturns the search results as a Generator. This allows you to iterate over the collection using the `next` method;\n\n```javascript\nlet gen = nerds.resolve('Harry Potter', 3).include(['first']).asGenerator();\ngen.next().value;  // {'first':'Harry'}\ngen.next().value;  // {'first':'Ron'}\ngen.next().value;  // {'first':'Hermione'}\ngen.next().value;  // undefined\n});\n```\n\n---\n\n## What's Next?\n\nnerdsJS is still under active development. Collecting, cleaning, compiling, and updating datasets are great ways to contribute. Just make sure that the data is consistent (they should all have the same keys and most of the fields should have some kind of data).\n\nTopics Yet To Be Added:\n- Super Mario\n- Sherlock\n- Lord Of The Rings\n- Avengers\n- Doctor Who\n- Star Trek\n- Dragonball Z\n- Zelda","funding_links":[],"categories":["JavaScript","Packages","包","Weird"],"sub_categories":["Weird","怪诞的","奇怪的"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSkyHacks%2Fnerds","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSkyHacks%2Fnerds","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSkyHacks%2Fnerds/lists"}