Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
parse-listing
Advanced tools
Simple library that parses file listing input for different platforms. An
example file listing is the output of the ls
command in unix, or the dir
command in DOS/Windows platforms.
var Parser = require("parse-listing");
// Yeah yeah, multiline strings would make Crockford mad, I know.
var str = "drwxr-xr-x 5 1001 1001 4096 Jan 09 11:52 .\r\n\
drwxr-xr-x 4 0 0 4096 Sep 19 13:50 ..\r\n\
-rw------- 1 1001 1001 1118 Jan 09 12:09 .bash_history\r\n\
-rw------- 1 1001 1001 943 Jan 09 11:52 .viminfo\r\n\
drwxrwxr-x 5 1001 1001 4096 Jan 09 11:52 inaccessible\r\n\
drwxrwxrwx 2 1001 1001 4096 Sep 21 11:20 project1\r\n\
drwx------ 2 1001 1001 4096 Oct 19 16:17 project2\r\n";
Parser.parseEntries(str, function(err, entryArray) {
entryArray.forEach(function(entry, i) {
console.log("Name:",entry.name);
console.log("Type", entry.type);
console.log("Size:", entry.size);
});
});
The example above will print the name, type and size for every entry in the listing. A parsed line becomes a JavaScript object like this:
{
type: 1,
size: 4096,
name: "project2",
time: 1382192220000,
owner: "1001",
group: "1001",
userPermissions: {
read: true,
write: true,
exec: true
},
groupPermissions: {
read: false,
write: false,
exec: false
},
otherPermissions: {
read: false,
write: false,
exec: false
}
}
Asynchronously parses a list of entries either in a single string (entries will be split by newlines) or in an array of strings. Invokes the callback when all the entries have been processed, and passes an array of JavaScript objects.
Parses a single string such as:
drwxrwxrwx 2 1001 1001 4096 Sep 21 11:20 project
and returns the JavaScript object for it. There is no need to specify whether the entry is in UNIX or MS-DOS/Windows format. The parser will find out by itself.
With NPM:
npm install parse-listing
From GitHub:
git clone https://github.com/sergi/parse-listing.git
The MIT License
Copyright(c) 2013 Sergi Mansilla <sergi.mansilla AT gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Small library to parse file listings into JavaScript objects
The npm package parse-listing receives a total of 168,039 weekly downloads. As such, parse-listing popularity was classified as popular.
We found that parse-listing demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.