{"id":15646177,"url":"https://github.com/tootallnate/stat-mode","last_synced_at":"2025-04-07T06:08:41.440Z","repository":{"id":14607829,"uuid":"17325045","full_name":"TooTallNate/stat-mode","owner":"TooTallNate","description":"Offers convenient getters and setters for the fs.stat()'s `mode`","archived":false,"fork":false,"pushed_at":"2019-11-08T01:22:21.000Z","size":30,"stargazers_count":50,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T04:08:18.533Z","etag":null,"topics":[],"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/TooTallNate.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":"2014-03-01T21:44:51.000Z","updated_at":"2024-09-17T03:38:29.000Z","dependencies_parsed_at":"2022-08-26T23:10:24.771Z","dependency_job_id":null,"html_url":"https://github.com/TooTallNate/stat-mode","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TooTallNate%2Fstat-mode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TooTallNate%2Fstat-mode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TooTallNate%2Fstat-mode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TooTallNate%2Fstat-mode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TooTallNate","download_url":"https://codeload.github.com/TooTallNate/stat-mode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247601448,"owners_count":20964864,"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":[],"created_at":"2024-10-03T12:11:42.180Z","updated_at":"2025-04-07T06:08:41.420Z","avatar_url":"https://github.com/TooTallNate.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"stat-mode\n=========\n### Offers convenient getters and setters for the stat `mode`\n[![Build Status](https://github.com/TooTallNate/stat-mode/workflows/Node%20CI/badge.svg)](https://github.com/TooTallNate/stat-mode/actions?workflow=Node+CI)\n\nYou know that `mode` property on the `fs.Stat` object that you probably\nusually just ignore? Well there's acutally a lot of information packed\ninto that number.\n\nThe specific information includes:\n\n * What the [\"file type\"](http://en.wikipedia.org/wiki/Unix_file_types) of file it is\n * Whether or not the [`setuid` and `setgid` bits](http://en.wikipedia.org/wiki/Setuid) are set\n * Whether or not the [`sticky` bit](http://en.wikipedia.org/wiki/Sticky_bit) is set\n * The [_read_, _write_, and _execute_ permissions for the _owner_, _group_ and _others_](http://en.wikipedia.org/wiki/File_system_permissions)\n\nThis module helps you extract that information.\n\nAll the getters are also setters, which change the `mode` property\nappropriately. This is useful for when you have to build up your\nown `fs.Stat` object for whatever reason (like when implementing a\nFUSE filesystem.\n\n\nInstallation\n------------\n\n``` bash\n$ npm install stat-mode\n```\n\n\nExample\n-------\n\nSo given some arbitrary file (let's say `/bin/echo`):\n\n``` bash\n$ ls -l /bin/echo\n-rwxr-xr-x 1 root wheel 14128 Aug 11  2013 /bin/echo\n```\n\nWe can inspect it using the `fs.stat()` call and creating a `Mode` instance\non top of it.\n\n``` javascript\nvar fs = require('fs');\nvar Mode = require('stat-mode');\n\nfs.stat('/bin/echo', function (err, stat) {\n  if (err) throw err;\n\n  // create a \"Mode\" instance on top of the `stat` object\n  var mode = new Mode(stat);\n\n  // you can check what kind of file it is:\n  mode.isDirectory();\n  // false\n\n  mode.isFIFO();\n  // false\n\n  mode.isFile();\n  // true\n\n\n  // and you can also check individual owner, group and others permissions\n  mode.owner.read;\n  // true\n\n  mode.owner.write;\n  // true\n\n  mode.owner.execute;\n  // true\n\n  mode.group.read;\n  // true\n\n  mode.group.write;\n  // false\n\n  mode.group.execute;\n  // true\n\n  mode.others.read;\n  // true\n\n  mode.others.write;\n  // false\n\n  mode.others.execute;\n  // true\n\n\n  // the `toString()` output resembes the `ls -l` output:\n  mode.toString();\n  // '-rwxr-xr-x'\n});\n```\n\n\nAPI\n---\n\n### new Mode(Object stat) → Mode\n\nYou must pass in \"stat\" object to the `Mode` constructor. The \"stat\"\nobject can be a real `fs.Stat` instance, or really any Object with a\n`mode` property.\n\n#### mode.isDirectory([Boolean set]) → Boolean\n\nReturns `true` if the mode's file type is \"directory\", `false` otherwise.\nIf you pass `true` to the function, then the mode will be set to \"directory\".\n\n#### mode.isFile([Boolean set]) → Boolean\n\nReturns `true` if the mode's file type is \"file\", `false` otherwise.\nIf you pass `true` to the function, then the mode will be set to \"file\".\n\n#### mode.isBlockDevice([Boolean set]) → Boolean\n\nReturns `true` if the mode's file type is \"block device\", `false` otherwise.\nIf you pass `true` to the function, then the mode will be set to \"block device\".\n\n#### mode.isCharacterDevice([Boolean set]) → Boolean\n\nReturns `true` if the mode's file type is \"character device\", `false` otherwise.\nIf you pass `true` to the function, then the mode will be set to \"character\ndevice\".\n\n#### mode.isSymbolicLink([Boolean set]) → Boolean\n\nReturns `true` if the mode's file type is \"symbolic link\", `false` otherwise.\nIf you pass `true` to the function, then the mode will be set to \"symbolic link\".\n\n#### mode.isFIFO([Boolean set]) → Boolean\n\nReturns `true` if the mode's file type is \"FIFO\", `false` otherwise.\nIf you pass `true` to the function, then the mode will be set to \"FIFO\".\n\n#### mode.isSocket([Boolean set]) → Boolean\n\nReturns `true` if the mode's file type is \"socket\", `false` otherwise.\nIf you pass `true` to the function, then the mode will be set to \"socket\".\n\n#### mode.owner.read → Boolean [Getter/Setter]\n\n`true` if the mode is \"owner read\" rights, `false` otherwise.\n\n#### mode.owner.write → Boolean [Getter/Setter]\n\n`true` if the mode is \"owner write\" rights, `false` otherwise.\n\n#### mode.owner.execute → Boolean [Getter/Setter]\n\n`true` if the mode is \"owner execute\" rights, `false` otherwise.\n\n#### mode.group.read → Boolean [Getter/Setter]\n\n`true` if the mode is \"group read\" rights, `false` otherwise.\n\n#### mode.group.write → Boolean [Getter/Setter]\n\n`true` if the mode is \"group write\" rights, `false` otherwise.\n\n#### mode.group.execute → Boolean [Getter/Setter]\n\n`true` if the mode is \"group execute\" rights, `false` otherwise.\n\n#### mode.others.read → Boolean [Getter/Setter]\n\n`true` if the mode is \"others read\" rights, `false` otherwise.\n\n#### mode.others.write → Boolean [Getter/Setter]\n\n`true` if the mode is \"others write\" rights, `false` otherwise.\n\n#### mode.others.execute → Boolean [Getter/Setter]\n\n`true` if the mode is \"others execute\" rights, `false` otherwise.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftootallnate%2Fstat-mode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftootallnate%2Fstat-mode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftootallnate%2Fstat-mode/lists"}