{"id":16236182,"url":"https://github.com/ganevdev/enough-time-ago","last_synced_at":"2026-05-16T22:05:57.351Z","repository":{"id":57225553,"uuid":"168529212","full_name":"ganevdev/enough-time-ago","owner":"ganevdev","description":"A Node.js library for checking how much time has passed since file was modified, changed, created or accessed.","archived":false,"fork":false,"pushed_at":"2019-04-01T07:27:02.000Z","size":52,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-02T04:19:45.005Z","etag":null,"topics":["filesystem","node","nodejs","time"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/enough-time-ago","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/ganevdev.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}},"created_at":"2019-01-31T13:25:34.000Z","updated_at":"2020-11-11T14:52:51.000Z","dependencies_parsed_at":"2022-08-24T10:40:22.620Z","dependency_job_id":null,"html_url":"https://github.com/ganevdev/enough-time-ago","commit_stats":null,"previous_names":["ganevru/enough-time-ago"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ganevdev/enough-time-ago","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ganevdev%2Fenough-time-ago","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ganevdev%2Fenough-time-ago/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ganevdev%2Fenough-time-ago/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ganevdev%2Fenough-time-ago/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ganevdev","download_url":"https://codeload.github.com/ganevdev/enough-time-ago/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ganevdev%2Fenough-time-ago/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33120456,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T18:38:32.183Z","status":"ssl_error","status_checked_at":"2026-05-16T18:38:29.903Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["filesystem","node","nodejs","time"],"created_at":"2024-10-10T13:29:33.020Z","updated_at":"2026-05-16T22:05:57.333Z","avatar_url":"https://github.com/ganevdev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Enough Time Ago\n\n[![Build Status](https://travis-ci.com/Ganevru/enough-time-ago.svg?branch=master)](https://travis-ci.com/Ganevru/enough-time-ago)\n[![npm](https://img.shields.io/npm/v/enough-time-ago.svg?style=flat-square)](http://npm.im/enough-time-ago)\n\nA [node js](https://nodejs.org/) library for checking how much time has passed since file was modified, changed, created or accessed. Always returns true, false or undefined (if file does not exist).\n\nThis library uses [node fs](https://nodejs.org/api/fs.html) methods, and its purpose is to shorten the code.\n\n```bash\nnpm i enough-time-ago\n```\n\nExamples with `modified`, same with `created`, `changed` or `accessed`.\n\n```js\nconst enoughTimeAgo = require('enough-time-ago');\n\nenoughTimeAgo('./newFile', 'modified', 10000);\n// return false, if file newFile modified less (or exactly 10000 ms) than 10 seconds ago\n\nenoughTimeAgo('./oldFile', 'modified', 10000);\n// return true, if file oldFile modified more than 10 seconds ago\n\nenoughTimeAgo('./nonFile', 'modified', 10000);\n// return undefined, if such file does not exist\n\nenoughTimeAgo('./newFile');\n// return false, if file newFile modified less (or exactly 86400000 ms) than one day ago\n// by default millisecond values are 86400000 ms (one day) and modified are default check\n```\n\nDelete file if it was last modified more than a 10 seconds ago.\nSame with `created`, `changed` and `accessed`.\n\n```js\nconst enoughTimeAgo = require('enough-time-ago');\nconst fs = require('fs');\n\nif (enoughTimeAgo('./file.html', 'modified', 10000)) {\n  fs.unlinkSync('./file.html');\n}\n// delete './file.html' if this file modified more than 10 seconds ago\n```\n\nExample - how to delete all obsolete (older than one day - 86400000 ms) files in a folder:\n\nRemember! This example can even delete the file that launched it.\n\n```js\nconst fs = require('fs');\nconst path = require('path');\nconst enoughTimeAgo = require('enough-time-ago');\n\n// This function removes the old file (which has been updated too long ago).\nfunction delOld(file, time) {\n  if (fs.existsSync(file)) {\n    if (enoughTimeAgo(file, 'modified', time)) {\n      fs.unlinkSync(file);\n    }\n  }\n}\n\n// This function deletes all old files with the specified extension in the specified folder.\nfunction delAllOld(folder, extension, time = 86400000) {\n  fs.readdirSync(folder).forEach((file) =\u003e {\n    if (file.split('.').pop() === extension) {\n      delOld(folder + '/' + file, time);\n    }\n  });\n}\n\ndelAllOld(path.resolve(__dirname, ''), 'html', 86400000);\n// This function delete ALL old files with the extension 'html' in the same folder that contains this script.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fganevdev%2Fenough-time-ago","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fganevdev%2Fenough-time-ago","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fganevdev%2Fenough-time-ago/lists"}