{"id":15612336,"url":"https://github.com/euberdeveloper/queryencoder","last_synced_at":"2025-03-29T15:13:03.332Z","repository":{"id":97420059,"uuid":"370840029","full_name":"euberdeveloper/queryencoder","owner":"euberdeveloper","description":"An npm module to encode an object into query params of an url","archived":false,"fork":false,"pushed_at":"2021-06-27T11:06:07.000Z","size":379,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-06T19:42:21.508Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://queryencoder.euber.dev","language":"TypeScript","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/euberdeveloper.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-25T22:09:05.000Z","updated_at":"2021-06-27T11:06:10.000Z","dependencies_parsed_at":"2023-05-29T07:15:45.014Z","dependency_job_id":null,"html_url":"https://github.com/euberdeveloper/queryencoder","commit_stats":{"total_commits":34,"total_committers":2,"mean_commits":17.0,"dds":0.02941176470588236,"last_synced_commit":"af5c1262896b17711373a2af02b89b6351ff30c5"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euberdeveloper%2Fqueryencoder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euberdeveloper%2Fqueryencoder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euberdeveloper%2Fqueryencoder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euberdeveloper%2Fqueryencoder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/euberdeveloper","download_url":"https://codeload.github.com/euberdeveloper/queryencoder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246200323,"owners_count":20739566,"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-10-03T06:41:50.503Z","updated_at":"2025-03-29T15:13:03.311Z","avatar_url":"https://github.com/euberdeveloper.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Lint](https://github.com/euberdeveloper/queryencoder/workflows/Lint/badge.svg)\n![Build](https://github.com/euberdeveloper/queryencoder/workflows/Build/badge.svg)\n![Test](https://github.com/euberdeveloper/queryencoder/workflows/Test/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/github/euberdeveloper/queryencoder/badge.svg?branch=main)](https://coveralls.io/github/euberdeveloper/queryencoder?branch=main)\n[![codecov](https://codecov.io/gh/euberdeveloper/queryencoder/branch/main/graph/badge.svg?token=4YW49XC338)](https://codecov.io/gh/euberdeveloper/queryencoder)\n[![Known Vulnerabilities](https://snyk.io/test/github/euberdeveloper/queryencoder/badge.svg?targetFile=package.json)](https://snyk.io/test/github/euberdeveloper/queryencoder?targetFile=package.json)\n[![dependencies Status](https://david-dm.org/euberdeveloper/queryencoder/status.svg)](https://david-dm.org/euberdeveloper/queryencoder)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![License](https://img.shields.io/npm/l/queryencoder.svg)](https://github.com/euberdeveloper/queryencoder/blob/master/LICENSE)\n[![GitHub issues](https://img.shields.io/github/issues/euberdeveloper/queryencoder.svg)](https://github.com/euberdeveloper/queryencoder/issues)\n[![GitHub stars](https://img.shields.io/github/stars/euberdeveloper/queryencoder.svg)](https://github.com/euberdeveloper/queryencoder/stargazers)\n![npm](https://img.shields.io/npm/v/queryencoder.svg)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![Types](https://img.shields.io/npm/types/queryencoder.svg)](https://www.npmjs.com/package/queryencoder)\n\n# queryencoder\nAn npm module to encode an object into query params of an url\n\n## Install\n\nTo install queryencoder, run:\n\n```bash\n$ npm install queryencoder\n```\n\n## Usage\n\n### Simple\n\n```js\nconst { encode } = require('queryencoder');\n\nconst object = {\n    str: 'string',\n    n: 23,\n    truthy: true\n};\n\n// The result is '?str=string\u0026n=23\u0026truthy=true'\nconst queryUrl = encode(object);\n```\n\n### With nested object\n\n```js\nconst { encode } = require('queryencoder');\n\nconst object = {\n    str: 'string',\n    nested: {\n        a: 'ciao'\n    }\n};\n\n// The result is '?str=string\u0026nested=true\u0026nested.a=ciao'\nconst queryUrl = encode(object);\n```\n\n### With some options\n\n```js\nconst { encode } = require('queryencoder');\n\nconst object = {\n    str: 'string',\n    shown: undefined,\n    nested: {\n        a: 'ciao'\n    },\n    vero: true\n};\n\n// The result is 'str=string\u0026nested.a=ciao\u0026vero'\nconst queryUrl = encode(object, {\n    preserveUndefined: true,\n    addQuestionMark: false,\n    flagNestedParents: false,\n    shortBoolean: true\n});\n```\n\n### With some dates\n\n```js\nconst { encode } = require('queryencoder');\n\nconst object = {\n    date: new Date('1999-04-23')\n};\n\n// The result is 'date=1999-04-23'\nconst queryUrl = encode(object, {\n    dateParser: date =\u003e date.toISOString().slice(0, 10)\n});\n```\n\n## API\n\nThe documentation site is: [queryencoder documentation](https://queryencoder.euber.dev)\n\nThe documentation for development site is: [queryencoder dev documentation](https://queryencoder-dev.euber.dev)\n\n### encode\n\nThe function to encode an object into an url query param string.\n\n**Syntax:**\n\n`const queryString = encode(object, options);`\n\n**Parameters:**\n\n* __object__: It is the object describing the parameters that should be encoded. It is an object that can be nested ad have values of type: string, number, boolean and Date.\n* __options__: Optional. It is the object containing the options.\n\n**Options parameters:**\n\n* __addQuestionMark__: Optional. A `boolean` that says if the `?` will be added to the begin of the result. Default value: `true`.\n* __shortBoolean__: Optional. If a value is of boolean type, it will be just declared if `true` while omitted if `false`. (e.g. `\u0026val`) Default value: `false`.\n* __flagNestedParents__: Optional. A `boolean` that says if in case there is a nested object, a parameter with value true for each path to the parents will be added. Default value: `true`.\n* __preserveNull__: Optional. A `boolean` that says if all the null values will be kept and parsed as 'null'. Default value: `true`.\n* __preserveUndefined__: Optional. A `boolean` that says if all the undefined values will be kept and parsed as 'undefined'. Default value: `false`.\n* __dateParser__: Optional. The function used to parse the dates. Default value: `value =\u003e value.toISOString()`.\n\n## Development\n\nTo build the module make sure you have the dev dependencies installed.\n\nThe project is written in `Typescript`, bundled with `Webpack` and linted with `ESLint`.\n\n### Lint\n\nIn order to lint the code:\n\n```bash\n$ npm run lint\n```\n\nIn order to lint and fix the code:\n\n```bash\n$ npm run lint:fix\n```\n\nThere are also the `:source` and `:test` suffix after `lint` in order to lint only the source code or the test code.\n\n### Transpile\n\nTo transpile both the source and the test code:\n\n```bash\n$ npm run transpile\n```\n\nThe `source` and the `test` folders will be transpiled in the `dist` folder. Also the `type declarations` will be generated.\n\n\nTo transpile only the source code:\n\n```bash\n$ npm run transpile:source\n```\n\nThe `source` folder will be transpiled in the `dist` folder. Also the `type declarations` will be generated.\n\n### Test\n\nAfter having transpiled the code, run:\n\n```bash\n$ npm test\n```\n\nin order to run the tests with `mocha`.\n\nIf a coverage report is to be generated, run:\n\n```bash\n$ npm run nyc\n```\n\n### Bundle\n\n```bash\n$ npm run bundle\n```\n\nThe `source` folder will be compiled in the `bundled` folder. It will contain the bundled `index.js` and `index.d.ts` files.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feuberdeveloper%2Fqueryencoder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feuberdeveloper%2Fqueryencoder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feuberdeveloper%2Fqueryencoder/lists"}