{"id":17033967,"url":"https://github.com/yisibell/pagein","last_synced_at":"2026-05-15T12:02:55.879Z","repository":{"id":57318098,"uuid":"449533364","full_name":"yisibell/pagein","owner":"yisibell","description":"A tiny pagination util function.","archived":false,"fork":false,"pushed_at":"2024-02-19T02:40:38.000Z","size":161,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-09T12:54:51.790Z","etag":null,"topics":["pagination","paging"],"latest_commit_sha":null,"homepage":"","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/yisibell.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2022-01-19T03:27:46.000Z","updated_at":"2023-03-18T13:54:31.000Z","dependencies_parsed_at":"2025-07-10T02:56:34.357Z","dependency_job_id":"f97f816f-268d-4500-8bf8-d2477b614733","html_url":"https://github.com/yisibell/pagein","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/yisibell/pagein","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yisibell%2Fpagein","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yisibell%2Fpagein/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yisibell%2Fpagein/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yisibell%2Fpagein/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yisibell","download_url":"https://codeload.github.com/yisibell/pagein/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yisibell%2Fpagein/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273453149,"owners_count":25108469,"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","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["pagination","paging"],"created_at":"2024-10-14T08:36:57.731Z","updated_at":"2026-05-15T12:02:55.818Z","avatar_url":"https://github.com/yisibell.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.org/package/pagein\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/pagein.svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://npmcharts.com/compare/pagein?minimal=true\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dm/pagein.svg\"\u003e\n  \u003c/a\u003e\n  \u003cbr\u003e\n\u003c/p\u003e\n\n# pagein\n\nA tiny paging util function.\n\n- [Release Notes](./CHANGELOG.md).\n\n# Installation\n\n``` bash\n# yarn\n$ yarn add pagein\n\n# npm\n$ npm i pagein\n```\n\n# APIs\n## paging\n\nSee [type definition](./src/interfaces/index.ts) here.\n\n```ts\nimport { paging } from 'pagein'\n```\n\n### Basic Usage\n\n-  Do not enable pagination, query based on conditions.\n\n``` js\nimport { paging } from 'pagein'\n\n// Original data\nconst originalData = [\n  { a: 'bar' },\n  { a: 'bar2' },\n  { a: 'foo' },\n  { a: 'foo2' }\n]\n\n// Define conditions\nconst conditions = [\n  { key: 'a', value: 'foo' }\n]\n\n// Query\nconst { total, data } = paging(originalData, { conditions } )\n\n// Results\nconsole.log(total) // 1\nconsole.log(data) // [{ a: 'foo' }]\n```\n\n- Enable pagination, query based on conditions.\n\n``` js\nimport { paging } from 'pagein'\n\n// Original data\nconst originalData = [\n  { a: 'bar' },\n  { a: 'bar2' },\n  { a: 'foo' },\n  { a: 'foo2' },\n  { a: 'foo2' },\n  { a: 'foo2' },\n  { a: 'foo' },\n  { a: 'foo' }\n]\n\n// Pagination control\nconst pagination = {\n  currentPage: 1, \n  pageSize: 2\n}\n\n// Define conditions\nconst conditions = [\n  { key: 'a', value: 'foo' }\n]\n\n// Query\nconst { total, data } = paging(originalData, { pagination , conditions })\n\n// Results\nconsole.log(total) // 3\nconsole.log(data) // [{ a: 'foo' }, { a: 'foo' }]\n```\n\n- Complex data structures.\n\n``` js\nimport { paging } from 'pagein'\n\n// Original data\nconst originalData = [\n  { a: { b: 'foo', c: 3 } },\n  { a: { b: 'foo2' } },\n  { a: { b: 'foo3' } },\n  { a: { b: 'foo', c: 2 } },\n  { a: { b: 'bar', c: 1 } },\n]\n\n// Define conditions\nconst conditions = [\n  { key: 'a.b', value: 'foo' }\n]\n\n// Query\nconst { total, data } = paging(originalData, { conditions })\n\n// Results\nconsole.log(total) // 2\nconsole.log(data) // [{ a: { b: 'foo', c: 3} }, { a: { b: 'foo', c: 2 } }]\n```\n\n- `fuzzy` condition.\n\n``` js\nimport { paging } from 'pagein'\n\n// Original data\nconst originalData = [\n  { a: 'hello' },\n  { a: 'hell' },\n  { a: '222hello' },\n  { a: 'hello111' },\n  { a: 'heaaallo' },\n]\n\n// Define conditions\nconst conditions = [\n  { key: 'a', value: 'hello', fuzzy: true }\n]\n\n// Query\nconst { total, data } = paging(originalData, { conditions })\n\n// Results\nconsole.log(total) // 3\nconsole.log(data) // [{ a: 'hello'}, { a: '222hello'}, { a: 'hello111'}]\n```\n\n- `daterange` condition.\n\n\n``` js\nimport { paging } from 'pagein'\n\n// Original data\nconst originalData = [\n  { date: '2023-01-02' },\n  { date: '2024-01-03' },\n  { date: '2020-01-02' },\n  { date: '2023-10-20' },\n  { date: '2023-01-09' },\n]\n\n// Define conditions\nconst conditions = [\n  { key: 'date', value: ['2023-01-01', '2023-01-10'], daterange: true }\n]\n\n// Query\nconst { total, data } = paging(originalData, { conditions })\n\n// Results\nconsole.log(total) // 2\nconsole.log(data) // [{ date: '2023-01-02' },  { date: '2023-01-09' }]\n```\n\n- `validHandler`.\n\n``` js\nimport { paging } from 'pagein'\n\n// Original data\nconst originalData = [\n  { a: 1, b: 2 },\n  { a: 3, b: 2 },\n  { a: 1, b: 5 },\n  { a: 1, b: 6 },\n  { a: 1, b: 2 },\n]\n\n// Define conditions\nconst conditions = [\n  { \n    key: 'a', \n    value: 3, \n    validHandler(conditionValue, originalValue) {\n      return conditionValue === originalValue\n    } \n  }\n]\n\n// Query\nconst { total, data } = paging(originalData, { conditions })\n\n// Results\nconsole.log(total) // 1\nconsole.log(data) // [{ a: 3, b: 2 }]\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyisibell%2Fpagein","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyisibell%2Fpagein","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyisibell%2Fpagein/lists"}