{"id":16244352,"url":"https://github.com/ralphtheninja/slump","last_synced_at":"2025-06-28T10:32:32.530Z","repository":{"id":27589620,"uuid":"31072642","full_name":"ralphtheninja/slump","owner":"ralphtheninja","description":"Create random JSON data.","archived":false,"fork":false,"pushed_at":"2020-05-25T04:09:50.000Z","size":37,"stargazers_count":6,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-27T17:39:34.388Z","etag":null,"topics":["json","random"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"dalavanmanphonsy/wptreport","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ralphtheninja.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-20T16:10:37.000Z","updated_at":"2019-08-11T22:29:58.000Z","dependencies_parsed_at":"2022-09-17T00:40:54.233Z","dependency_job_id":null,"html_url":"https://github.com/ralphtheninja/slump","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphtheninja%2Fslump","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphtheninja%2Fslump/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphtheninja%2Fslump/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphtheninja%2Fslump/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ralphtheninja","download_url":"https://codeload.github.com/ralphtheninja/slump/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232028811,"owners_count":18462508,"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":["json","random"],"created_at":"2024-10-10T14:18:42.002Z","updated_at":"2024-12-31T20:56:55.887Z","avatar_url":"https://github.com/ralphtheninja.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# slump\n\n\u003e Create random json.\n\n[![npm](https://img.shields.io/npm/v/slump.svg)](https://www.npmjs.com/package/slump)\n![Node version](https://img.shields.io/node/v/slump.svg)\n[![Build Status](https://travis-ci.org/ralphtheninja/slump.svg?branch=master)](https://travis-ci.org/ralphtheninja/slump)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\nPorted from [`node-random-json`](https://github.com/maxtaco/node-random-json).\n\n## Install\n\n```\n$ npm install slump --save\n```\n\n## Usage\n\nGenerate a random json object:\n\n```js\nconst random = require('slump')\nconsole.log(JSON.stringify(random.json(), null, 2))\n```\n\n```json\n[\n  [\n    null,\n    0.7102621181796653,\n    []\n  ]\n]\n```\n\n## Api\n\n### `random.bytes([size])`\n\nReturns a buffer of random bytes of size `size`, which defaults to one.\n\n### `random.byte()`\n\nReturns a single random byte.\n\n### `random.integer([signed])`\n\nReturns a 32 bit integer. If `signed` is trueish both negative and positive values are generated. Default is non signed integers.\n\n### `random.float()`\n\nReturns a float as a result of division of two random integers. Random floats are always signed.\n\n### `random.string([options[, length]])`\n\nReturns a random string in `utf8` encoding.\n\nIf `length` is omitted the string length is a random integer between `0` and `100`. So the string can be empty.\n\nRandomizes a much longer string of bytes and cuts it off to appropriate length.\n\n`options` can be used for different encodings:\n\n* `options.enc` *(string)* Defaults to `utf8`. Valid encodings are `utf8`, `ascii`, `hex`, `base64` and `base58`\n* `options.length` *(number)* Length of string.\n* `options.values` *(array)* Array of predetermined strings.\n\n```js\nconst random = require('slump')\n// random string with random length\nconst s1 = random.string()\n// random string with length 20\nconst s2 = random.string(20)\n// random base58 encoded string with length 30\nconst s3 = random.string({ enc: 'base58', length: 30 })\n// randomize between predetermined values\nconst values = [ 'apples', 'oranges', 'bananas' ]\nconst s4 = random.string({ values: values })\n```\n\n### `random.array([length])`\n\nReturns a fixed `length` random array where the elements are random json values, i.e. the elements can be anything from null, false, true, another json object etc.\n\nIf `length` is omitted the string length is a random integer between `0` and `10`. So the array can be empty.\n\n### `random.obj([size])`\n\nReturns a random object with `size` number of random keys and values. Each property is a `random.string()` (with random length) and each value is a `random.json()`.\n\nIf `size` is omitted the number of properties is a random integer between `0` and `10`. So the object can be empty.\n\n### `random.json()`\n\nGenerates a random `json` object value, i.e. either of the following:\n\n* `false`\n* `true`\n* `null`\n* `random.integer()`\n* `random.float()`\n* `random.string()`\n* `random.array()`\n* `random.obj()`\n\n## Todo\n\n* Configuration for changing default behaviors and also per single operations, i.e. default lengths of strings etc.\n* More advanced schemas. It could be useful to generate random data that still follows a defined structure, perhaps you want arrays of only strings, number intervals and things like that.\n\n## License\nAll code, unless stated otherwise, is licensed under the [`WTFPL`](http://www.wtfpl.net/txt/copying/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fralphtheninja%2Fslump","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fralphtheninja%2Fslump","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fralphtheninja%2Fslump/lists"}