{"id":17281521,"url":"https://github.com/sumory/basen","last_synced_at":"2025-04-14T10:02:43.113Z","repository":{"id":9582440,"uuid":"11498761","full_name":"sumory/baseN","owner":"sumory","description":"Encode number to base(2~62) hash string and decode it back.","archived":false,"fork":false,"pushed_at":"2013-07-21T07:42:34.000Z","size":124,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-22T12:48:10.066Z","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/sumory.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":"2013-07-18T09:10:31.000Z","updated_at":"2021-05-22T17:24:42.000Z","dependencies_parsed_at":"2022-07-30T01:37:52.749Z","dependency_job_id":null,"html_url":"https://github.com/sumory/baseN","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/sumory%2FbaseN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sumory%2FbaseN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sumory%2FbaseN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sumory%2FbaseN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sumory","download_url":"https://codeload.github.com/sumory/baseN/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240183835,"owners_count":19761443,"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-15T09:46:06.348Z","updated_at":"2025-02-25T04:32:52.802Z","avatar_url":"https://github.com/sumory.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# baseN [![Build Status](https://travis-ci.org/sumory/baseN.png?branch=master)](https://travis-ci.org/sumory/baseN) \n\n**baseN**: Encode number(max is Math.pow(2,53)) to base(2~62) hash string and decode it back. Customization is also supported.\n\n\n## Install\n\n```bash\n$ npm install basen\n```\n\n## Usage\n\nsee [baseN.test.js](https://github.com/sumory/baseN/blob/master/test/baseN.test.js) for detail.\n\n#### new BaseN()\n\nThree ways to start with `baseN`\n\n```\nvar BaseN = require('basen');\nvar baseN = new BaseN();//use default base array: letter(52) + numeric(10)\nvar baseN = new BaseN(15);//set radix 15, and use first 1~15 chars as base array\nvar baseN = new BaseN({\n    base:[\n        'a','b','c','d','e','0','1','2'\n    ]\n});//customize base array\n```\n\n#### encode()\n\nconvert number to hash string\n\n```\nvar testCase = [\n    [0, '0'],\n    [1, '1'],\n    [20, 'k'],\n    [1000, 'g8'],\n    [20130718, '1msV0']\n];\nvar baseN = new BaseN();\n\ntestCase.forEach(function(item) {\n    baseN.encode(item[0]);\n});\n```\n\n#### decode()\n\nconvert hash string to the origin number\n\n```\nvar testCase = [\n    [0, '0'],\n    [1, '1'],\n    [20, 'k'],\n    [1000, 'g8'],\n    [20130718, '1msV0']\n];\nvar baseN = new BaseN();\n\ntestCase.forEach(function(item) {\n    baseN.decode(item[1]);\n});\n```\n\n#### reBase()\n\nchange base array to a random base array\n\n```\nvar baseN = new BaseN();\nbaseN.reBase(10);//select 10 chars from default base array as new base array\nbaseN.base.length == 10;//true\n\nvar testCase = [0, 1, 20, 1000, 1024, 123456789];\ntestCase.forEach(function(item) {\n    baseN.decode(baseN.encode(item))==item;//true\n});\n```\n\n\n\n## License\n\nbaseN is released under a **MIT License**:\n\n    Copyright (C) 2013 by Sumory Wu \u003csumory.wu@gmail.com\u003e\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy\n    of this software and associated documentation files (the \"Software\"), to deal\n    in the Software without restriction, including without limitation the rights\n    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n    copies of the Software, and to permit persons to whom the Software is\n    furnished to do so, subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in\n    all copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n    THE SOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsumory%2Fbasen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsumory%2Fbasen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsumory%2Fbasen/lists"}