{"id":22328723,"url":"https://github.com/seangenabe/kanasort","last_synced_at":"2025-07-29T18:31:37.308Z","repository":{"id":36668008,"uuid":"40974375","full_name":"seangenabe/kanasort","owner":"seangenabe","description":"Sort Japanese text.","archived":false,"fork":false,"pushed_at":"2018-08-03T01:35:02.000Z","size":51,"stargazers_count":7,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-08-09T13:43:44.554Z","etag":null,"topics":["hiragana","katakana","sort","sorting-algorithm"],"latest_commit_sha":null,"homepage":null,"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/seangenabe.png","metadata":{"files":{"readme":"readme-customizable-api.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-18T13:44:12.000Z","updated_at":"2024-02-20T11:01:55.000Z","dependencies_parsed_at":"2022-07-11T10:31:42.882Z","dependency_job_id":null,"html_url":"https://github.com/seangenabe/kanasort","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seangenabe%2Fkanasort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seangenabe%2Fkanasort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seangenabe%2Fkanasort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seangenabe%2Fkanasort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seangenabe","download_url":"https://codeload.github.com/seangenabe/kanasort/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228034824,"owners_count":17859246,"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":["hiragana","katakana","sort","sorting-algorithm"],"created_at":"2024-12-04T03:13:19.664Z","updated_at":"2024-12-04T03:13:20.153Z","avatar_url":"https://github.com/seangenabe.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Customizable API\n\nCustomizable parts of the API.\n\n## API\n\n### class kanasort.Sorter\n\nThe Sorter class is the main customizable element of this module.\n\nThe Sorter goes through each Transform, transforms it to a simpler form, and\nin the process assigns a weight to each character. When comparing two strings,\nthey are transformed first, then evaluated character-by-character while taking\ninto consideration the weights assigned by the `Transform` instances.\n\n#### #constructor(transforms, opts)\n\nInitializes a new instance of `Sorter`.\n* `transforms`\n  * `transformsfn(str: string): Transform[]`:\n  * `weights: number[]`\n* `opts`\n  * `transformCache: object`: LRUCache options\n  * `compareCache: object`: MKC options\n\n#### #transform(str: string): TransformedString\n\nTransforms the string using `#transforms`, assigning a weight to each character.\nCache-enabled.\n\n#### #compare(a: string, b: string): number\n\nCompares two strings. Cache-enabled.\n\n#### Sorter.default\n\nReturns a singleton instance of Sorter. Used by `kanasort` and\n`kanasort.compare`.\n\n#### #transformCache: LRUCache\u003cstring, TransformedString\u003e\n\nAn LRU cache of transformed strings. Can be set after calling the constructor\nto override. Set to null to disable.\n\n#### #compareCache: MultiKeyCache\u003c[string, string], number\u003e\n\nA multi-key LRU cache of comparisons. Can be set after calling the constructor\nto override. Set to null to disable.\n\n#### #initializeTransformCache(opts: object = {})\n\n(Re-)initializes the transform cache. Use if you just want to modify the\noptions passed to the `lru-cache` constructor.\n\n### class kanasort.WeightedCharacterTransform\n\n`WeightedCharacterTransform` is the base class of all transforms used by this\nmodule. It processes each character of a string and assigns a weight to it. A\nlesser weight goes before a greater weight.\n\nAn instance is constructed for each string.\n\n#### #transform(tc: TransformedCharacter)\n\nReturns an instruction that instructs how to transform the specified `TransformedCharacter` instance:\n* `null` or `undefined`: No transformation should be done to the character.\n* Array: [str: string, weight: number]: The character should be transformed to `str` with `weight` weight.\n* Array: [null]: The character should be discarded.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseangenabe%2Fkanasort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseangenabe%2Fkanasort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseangenabe%2Fkanasort/lists"}