{"id":23186077,"url":"https://github.com/termosa/qinu","last_synced_at":"2025-04-05T04:44:59.296Z","repository":{"id":58235141,"uuid":"82077850","full_name":"termosa/qinu","owner":"termosa","description":"Highly customizable generator of [random] strings","archived":false,"fork":false,"pushed_at":"2018-02-03T14:00:30.000Z","size":56,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T05:01:43.221Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/termosa.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":"2017-02-15T15:53:16.000Z","updated_at":"2019-07-08T23:31:10.000Z","dependencies_parsed_at":"2022-08-31T09:21:17.148Z","dependency_job_id":null,"html_url":"https://github.com/termosa/qinu","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/termosa%2Fqinu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/termosa%2Fqinu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/termosa%2Fqinu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/termosa%2Fqinu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/termosa","download_url":"https://codeload.github.com/termosa/qinu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247123107,"owners_count":20887261,"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-12-18T10:14:25.298Z","updated_at":"2025-04-05T04:44:59.275Z","avatar_url":"https://github.com/termosa.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# qinu [![NPM version](https://img.shields.io/npm/v/qinu.svg?style=flat-square)](https://www.npmjs.com/package/qinu) [![Bower version](https://img.shields.io/bower/v/qinu.svg?style=flat-square)](https://github.com/termosa/qinu) [![Travis](https://img.shields.io/travis/termosa/qinu.svg?style=flat-square)](https://travis-ci.org/termosa/qinu)\n\nHighly customizable generator of [random] strings.\n\n## Installation\n\n### Via NPM\n\nInstall the package\n\n```bash\n$ npm install qinu\n```\n\nrequire it\n\n```js\nconst qinu = require('qinu')\n```\n\n### Via Bower\n\nInstall the package\n\n```bash\n$ bower install qinu\n```\n\nadd script on page\n\n```html\n\u003cscript src=\"/bower_components/qinu/qinu.min.js\"\u003e\u003c/script\u003e\n```\n\nas well you can do it with [RequireJS](http://requirejs.org/) or any similar tool.\n\n## Usage\n\n### Basic usage\n\n```js\n// Generates 32-character random string, e.g. '4plugjpebgyqduvwcy7lo74wj4idxu5w'\nconst randomString = qinu()\n```\n\n### Using with options\n\n```js\n// Generates 64-character random string\n// that contains only hexadecimal numbers,\n// e.g. 'df6x4ou3p5tar625301dfuftqd8rh9kxwcjl6t0mtmxke3a9q8wuu3nhvrtrn3na'\nconst randomString = qinu({\n  // The length of output string\n  length: 64,\n  // The set of characters to be used by qinu\n  dict: '1234567890abcdef'\n})\n```\n\n### Using with template\n\n```js\n// Generates string corresponding to template,\n// e.g. 'LABEL: hjwjd4hk4cpx7b1ekh9vdmvsnob228bf SUFIX'\nconst randomString = qinu(\n  // Set template for output string\n  { template: '%arg[0]%: %qinu% %arg[1]%' },\n  // Pass arguments for template\n  [ 'LABEL', 'SUFIX' ]\n)\n```\n\n`%qinu%` will be replaced with generated random string. Each passed argument will replace the relative code `%arg[\u003cindex\u003e]%`.\n\nInstead of array you can pass all template arguments as function arguments:\n\n```js\n// It works the same as an example above\nconst randomString = qinu(\n  // Set template for output string\n  { template: '%arg[0]%: %qinu% %arg[1]%' },\n  // Pass arguments for template\n  'LABEL',\n  'SUFIX'\n)\n```\n\nThere is another option to pass arguments to the template, via `args` option:\n\n```js\n// Still, the same as examples above\nconst randomString = qinu({\n  template: '%arg[0]%: %qinu% %arg[1]%',\n  args: [ 'LABEL', 'SUFIX' ]\n})\n```\n\nIn case when both described options will be used arguments will be merged: `args` from the options object will be in the beginning and arguments from the function argument will be in the end:\n\n```js\n// Still, no difference\nconst randomString = qinu(\n  {\n    template: '%arg[0]%: %qinu% %arg[1]%',\n    args: [ 'LABEL' ]\n  },\n  'SUFIX'\n)\n```\n\n### Using predefined options\n\nYou can create qinu-generator with predefined options:\n\n```js\nconst qinuCustom = qinu.create({\n  template: '%arg[0]%-%arg[1]%-%qinu%'\n})\n\n// Generates string corresponding to template,\n// e.g. 'group-label-wh0qothao58nk0zno2g86ct4gl3j9wa7'\nconst randomString = qinuCustom('group', 'label')\n// or use it with array\nconst anotherRandomString = qinuCustom(['group', 'label'])\n```\n\n\u003e When using `qinu.create()` generated results are ordered in a sequence. This behavior can be changed using [`random` option](#generating-unique-sequence-random-option)\n\n### Shortcut for length property\n\nIn case you need to specify only the `length`:\n\n```js\n// Generates 64-character random string\nconst randomString = qinu(64)\n\n// The shortcut can be applied to create method as well:\nconst generateRandom10Characters = qinu.create(10)\n// Generate 10-character random string\nconst randomString = generateRandom10Characters()\n```\n\n### Generating unique sequence (random option)\n\nIn case if absolute uniqueness is required during the session, `qinu.create()` creates a function that first generate a random value and then iterate it one-by-one. This makes it impossible to generate the same string unless all possible combinations wasn't generated.\n\n```js\nconst next = qinu.create({ length: 3, dict: 'abc' })\nnext() // 'abb'\nnext() // 'abc'\nnext() // 'aca'\n```\n\nIf randomness is preferred pass `random: true` when create generator:\n\n```js\nconst generate = qinu.create({ random: true, length: 3, dict: 'abc' })\ngenerate() // 'ccb'\ngenerate() // 'aaa'\ngenerate() // 'baa'\n```\n\n## License\n\nMIT © [Stanislav Termosa](https://github.com/termosa)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftermosa%2Fqinu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftermosa%2Fqinu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftermosa%2Fqinu/lists"}