{"id":17398219,"url":"https://github.com/codeman99/stats-ctor","last_synced_at":"2026-02-03T11:33:42.449Z","repository":{"id":57370244,"uuid":"127345327","full_name":"CodeMan99/stats-ctor","owner":"CodeMan99","description":"nodejs fs.Stats constructor with sane signature and defaults.","archived":false,"fork":false,"pushed_at":"2024-11-28T20:27:28.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-28T21:26:43.718Z","etag":null,"topics":["fs","node","stats"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CodeMan99.png","metadata":{"files":{"readme":"README.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":"2018-03-29T20:42:11.000Z","updated_at":"2024-11-28T20:27:32.000Z","dependencies_parsed_at":"2022-09-26T16:41:08.605Z","dependency_job_id":null,"html_url":"https://github.com/CodeMan99/stats-ctor","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeMan99%2Fstats-ctor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeMan99%2Fstats-ctor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeMan99%2Fstats-ctor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeMan99%2Fstats-ctor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CodeMan99","download_url":"https://codeload.github.com/CodeMan99/stats-ctor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228528318,"owners_count":17933284,"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":["fs","node","stats"],"created_at":"2024-10-16T14:42:27.478Z","updated_at":"2026-02-03T11:33:42.418Z","avatar_url":"https://github.com/CodeMan99.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stats-ctor [![Build Status](https://travis-ci.org/CodeMan99/stats-ctor.svg?branch=master)](https://travis-ci.org/CodeMan99/stats-ctor)\n\n[`fs.Stats`](https://nodejs.org/dist/latest/docs/api/fs.html#fs_class_fs_stats) constructor with a sane signature and defaults.\n\n## DEPRECATED\n\nThe upstream `fs.Stats` constructor was deprecated as of nodejs v20.13.0 \u0026 v22.0.0\n\n## Usage\n\nSane defaults.\n\n```javascript\nvar Stats = require('stats-ctor');\nvar stat = new Stats();\n\nconsole.log(stat.mode);  // 0\nconsole.log(stat.uid);   // 1000  -  from `process.getuid()`\nconsole.log(stat.mtime); // 2018-03-29T17:01:48.883Z  -  from `new Date()`\n```\n\nSane single argument signature.\n\n```javascript\nvar fs = require('fs');\nvar Stats = require('stats-ctor');\nvar umask = 0o002;\nvar stat = new Stats({\n\tmode: fs.constats.S_IFREG | (umask ^ 0o777)\n});\n\nconsole.log(stat.mode); // 33277\n```\n\nFree copy constructor.\n\n```javascript\nvar fs = require('fs');\nvar Stats = require('stats-ctor');\nvar stat = fs.statSync('./README.md');\nvar copy = new Stats(stat);\n\nconsole.log(stat === copy); // false\nconsole.log(stat.mtime.getTime() === copy.mtime.getTime()); // true  -  same for all properties on the copy instance\n```\n\n## API\n\n### Stats([options])\n\nIdentical to the `fs.Stats` constructor in node core, except it has a single\noptions argument instead of _fourteen_ named arguments.\n\n#### options\n\nType: `Object`\n\nSimply uses the named arguments from `fs.Stats` as property names.\n\n##### dev\n\nType: `Number`\n\u003cbr\u003eDefault: `0`\n\n##### mode\n\nType: `Number`\n\u003cbr\u003eDefault: `0`\n\nYou should create a real mode for most use cases. See [`fs.constants`](https://nodejs.org/dist/latest/docs/api/fs.html#fs_file_type_constants). For example when creating a new regular file do `fs.constants.S_IFREG | (process.umask() ^ 0o666)`.\n\n##### nlink\n\nType: `Number`\n\u003cbr\u003eDefault: `0`\n\n##### uid\n\nType: `Number`\n\u003cbr\u003eDefault: `process.getuid()`\n\n##### gid\n\nType: `Number`\n\u003cbr\u003eDefault: `process.getgid()`\n\n##### rdev\n\nType: `Number`\n\u003cbr\u003eDefault: `0`\n\n##### blksize\n\nType: `Number`\n\u003cbr\u003eDefault: `0`\n\n##### ino\n\nType: `Number`\n\u003cbr\u003eDefault: `0`\n\n##### size\n\nType: `Number`\n\u003cbr\u003eDefault: `0`\n\n##### blocks\n\nType: `Number`\n\u003cbr\u003eDefault: `0`\n\n##### atim_msec\n\nType: `Number`\n\u003cbr\u003eDefault: `Date.now()`\n\nThis property creates a `Date` instance called `atime`.\n\n##### mtim_msec\n\nType: `Number`\n\u003cbr\u003eDefault: `Date.now()`\n\nThis property creates a `Date` instance called `mtime`.\n\n##### ctim_msec\n\nType: `Number`\n\u003cbr\u003eDefault: `Date.now()`\n\nThis property creates a `Date` instance called `ctime`.\n\n##### birthtim_msec\n\nType: `Number`\n\u003cbr\u003eDefault: `Date.now()`\n\nThis property creates a `Date` instance called `birthtime`.\n\n#### Stats.prototype.atim_msec\n\nType: `Number`\n\nA millisecond getter/setter for `atime`.\n\u003cbr\u003eIf available on the instance, setter will update `atimeMs`.\n\n#### Stats.prototype.mtim_msec\n\nType: `Number`\n\nA millisecond getter/setter for `mtime`.\n\u003cbr\u003eIf available on the instance, setter will update `mtimeMs`.\n\n#### Stats.prototype.ctim_msec\n\nType: `Number`\n\nA millisecond getter/setter for `ctime`.\n\u003cbr\u003eIf available on the instance, setter will update `ctimeMs`.\n\n#### Stats.prototype.birthtim_msec\n\nType: `Number`\n\nA millisecond getter/setter for `birthtime`.\n\u003cbr\u003eIf available on the instance, setter will update `birthtimeMs`.\n\n## Warning\n\nNode added millisecond properties starting with *v8.1.0*. However, these are\ninstance properties and are disconnected with the `Date` equivalent. For\nexample, updating `stat.mtimeMs` will not update `stat.mtime`.\n\nAs such this module makes `atimeMs`, `ctimeMs`, `mtimeMs`, \u0026 `birthtimeMs`\nnon-enumerable. Instead use the prototype properties above.\n\n## Related\n\n * [clone-stats](https://github.com/hughsk/clone-stats) Copying existing `fs.Stats` instances.\n * [stat-mode](https://github.com/TooTallNate/stat-mode) Sane handling of the `mode` property.\n\n## License\n\nISC - Copyright \u0026copy; 2018, Cody A. Taylor.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeman99%2Fstats-ctor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeman99%2Fstats-ctor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeman99%2Fstats-ctor/lists"}