{"id":19463023,"url":"https://github.com/poppinlp/file-changed","last_synced_at":"2025-06-18T02:36:49.679Z","repository":{"id":26280235,"uuid":"29727766","full_name":"poppinlp/file-changed","owner":"poppinlp","description":"A node module to check and store file changed.","archived":false,"fork":false,"pushed_at":"2022-12-29T03:42:09.000Z","size":382,"stargazers_count":7,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-23T23:42:22.506Z","etag":null,"topics":["chain-operation","changed","file","md5","mtime","newer","timestamp"],"latest_commit_sha":null,"homepage":"https://github.com/poppinlp/file-changed","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/poppinlp.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}},"created_at":"2015-01-23T10:21:32.000Z","updated_at":"2021-05-26T09:29:48.000Z","dependencies_parsed_at":"2023-01-14T04:19:53.149Z","dependency_job_id":null,"html_url":"https://github.com/poppinlp/file-changed","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/poppinlp/file-changed","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poppinlp%2Ffile-changed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poppinlp%2Ffile-changed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poppinlp%2Ffile-changed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poppinlp%2Ffile-changed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/poppinlp","download_url":"https://codeload.github.com/poppinlp/file-changed/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poppinlp%2Ffile-changed/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260475859,"owners_count":23014929,"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":["chain-operation","changed","file","md5","mtime","newer","timestamp"],"created_at":"2024-11-10T18:07:57.190Z","updated_at":"2025-06-18T02:36:44.660Z","avatar_url":"https://github.com/poppinlp.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# file-changed\n\n[![Build Status][ci-img]][ci-url]\n[![Code coverage][cov-img]][cov-url]\n[![Code style][lint-img]][lint-url]\n[![Dependency Status][dep-img]][dep-url]\n[![Dev Dependency Status][dev-dep-img]][dev-dep-url]\n[![NPM version][npm-ver-img]][npm-url]\n[![NPM downloads][npm-dl-img]][npm-url]\n[![NPM license][npm-lc-img]][npm-url]\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fpoppinlp%2Ffile-changed.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fpoppinlp%2Ffile-changed?ref=badge_shield)\n\nA node module to check and store file changed.\n\n## Install\n\nBy npm:\n\n```shell\nnpm i file-changed --save\n```\n\nBy yarn:\n\n```shell\nyarn add file-changed\n```\n\n## Class\n\nThis package export a class since version 1.0.0 which means you could have multiple instances and save the information where you like.\n\n### constructor([dbPath])\n\n#### Arguments\n\n##### dbPath {string}\n\n* Default: `./\\_timestamp.json`\n\nPath to save collection informations on disk.\n\n#### Return\n\nCollection instance.\n\n## Instance Methods\n\n### get(file[, type])\n\nAccess to a file last modified information.\n\n#### Arguments\n\n* file {string}: The target file path\n* type {string}: The information type\n  * `ts`: timestamp (default)\n  * `md5`: md5 hash\n\n#### Return\n\n* `false` {boolean}: no such file in collection\n* timestamp or md5 {string}: depends on `type`\n\n### list()\n\nGet all file paths in collection.\n\n#### Return\n\n* file paths {array}\n\n### addFile(path[, path2 ... pathN])\n\nAdd files to collection.\n\n#### Arguments\n\n* path {string}: the target file path or glob\n\n#### Return\n\n* `this` {object}: for chain operation\n\n### rmFile(path[, path2 ... pathN])\n\nRemove files from collection.\n\n#### Arguments\n\n* path {string}: the target file path or glob\n\n#### Return\n\n* `this` {object}: for chain operation\n\n### check([path1 ... pathN])\n\nCheck collection files changed or not.\n\n#### Arguments\n\n* no arguments: check all files.\n* path {string}: the target file path or glob\n\n#### Return\n\n* changed files {array}\n\n### update([path1 ... pathN])\n\nUpdate files last modified information.\n\n#### Arguments\n\n* no arguments: update all files\n* path {string}: the target file path or glob\n\n#### Return\n\n* `this` {object}: for chain operation\n\n### clean()\n\nClean files in collection which could not found.\n\n#### Return\n\n* `this` {object}: for chain operation\n\n### save()\n\nSave collection information onto disk.\n\n#### Return\n\n* `this` {object}: for chain operation\n\n## Usage Examples\n\n```js\nconst Fc = require('file-changed');\nconst collectionA = new Fc('./path/to/save/info'); // Create collection instance whill will load modified info from that path if that path exists\n\ncollectionA.addFile('test/files/file1', 'test/files/file2'); // Add 2 files in collectionA\n\nconst fileList = collectionA.list(); // Get file list in collectionA\n\ncollectionA.rmFile('test/files/file1'); // Remove 1 file from collectionA\n\ncollectionA.addFile('test/files/*'); // Add file by glob\n\nconst modifiedList1 = collectionA.check('test/files/file1'); // Check 1 file modified or not\nconst modifiedList2 = collectionA.check()); // Check all files in collectionA modified or not\n\ncollectionA.update('test/files/file1'); // Update last modified info for 1 file\ncollectionA.update(); // Update last modified info for all files in collectionA\n\nconst lastModifiedTS = collectionA.get('test/files/file1'); // Get last modified timestamp for that file\nconst lastModifiedMD5 = collectionA.get('test/files/file1', 'md5'); // Get last modified md5 for that file\n\ncollectionA.save(); // Save collectionA modified info to disk\n```\n\n## Test\n\n```shell\nnpm test\n```\n\n[ci-img]: https://img.shields.io/travis/poppinlp/file-changed.svg?style=flat-square\n[ci-url]: https://travis-ci.org/poppinlp/file-changed\n[cov-img]: https://img.shields.io/coveralls/poppinlp/file-changed.svg?style=flat-square\n[cov-url]: https://coveralls.io/github/poppinlp/file-changed?branch=master\n[lint-img]: https://img.shields.io/badge/code%20style-handsome-brightgreen.svg?style=flat-square\n[lint-url]: https://github.com/poppinlp/eslint-config-handsome\n[dep-img]: https://img.shields.io/david/poppinlp/file-changed.svg?style=flat-square\n[dep-url]: https://david-dm.org/poppinlp/file-changed\n[dev-dep-img]: https://img.shields.io/david/dev/poppinlp/file-changed.svg?style=flat-square\n[dev-dep-url]: https://david-dm.org/poppinlp/file-changed#info=devDependencies\n[npm-ver-img]: https://img.shields.io/npm/v/file-changed.svg?style=flat-square\n[npm-dl-img]: https://img.shields.io/npm/dm/file-changed.svg?style=flat-square\n[npm-lc-img]: https://img.shields.io/npm/l/file-changed.svg?style=flat-square\n[npm-url]: https://www.npmjs.com/package/file-changed\n\n## License\n\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fpoppinlp%2Ffile-changed.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fpoppinlp%2Ffile-changed?ref=badge_large)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoppinlp%2Ffile-changed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpoppinlp%2Ffile-changed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoppinlp%2Ffile-changed/lists"}