Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
file-normalize
Advanced tools
File system utils for normalizing things like eol, encoding and BOM.
File system utils for normalizing things like eol, encoding and BOM.
Install with npm:
$ npm install --save file-normalize
Install with yarn:
$ yarn add file-normalize
Normalize slashes in the given filepath to forward slashes. Note that this is a simple replacement of \\
with /
, and this method does not check for URL or windows drive characters.
Params
filepath
{String}returns
{String}Example
var file = require('file-normalize');
console.log(file.normalizeSlash('foo\\bar'));
//=> 'foo/bar'
Normalize line endings to use the given eol
character, or the defaults of the current operating system.
Params
str
{String}returns
{String}Example
var fs = require('fs');
var file = require('file-normalize');
var str = fs.readFileSync('foo.txt', 'utf8');
console.log(file.normalizeEOL(str));
Normalize all line endings to unix newlines (strips carriage returns).
Params
str
{String}returns
{String}Example
var fs = require('fs');
var file = require('file-normalize');
var str = fs.readFileSync('foo.txt', 'utf8');
console.log(file.normalizeNL(str));
Strip byte-order marks.
Params
val
{String|Buffer}returns
{String}Example
var fs = require('fs');
var file = require('file-normalize');
var str = file.readFileSync('foo.txt', 'utf8');
console.log(file.stripBOM(str));
Append a string or buffer to another string or buffer ensuring to preserve line ending characters.
Params
prefix
{String|Buffer}: String or Buffer that will be used to check for an existing line ending. The suffix is appended to this.suffix
{String|Buffer}: String or Buffer that will be appended to the prefix.returns
{String|Buffer}: Final String or BufferExample
console.log([append(new Buffer('abc\r\n'), new Buffer('def')).toString()]);
//=> [ 'abc\r\ndef\r\n' ]
console.log([append(new Buffer('abc\n'), new Buffer('def')).toString()]);
//=> [ 'abc\ndef\n' ]
// uses os.EOL when a line ending is not found
console.log([append(new Buffer('abc'), new Buffer('def')).toString()]);
//=> [ 'abc\ndef' ]
console.log([append('abc\r\n', 'def')]);
//=> [ 'abc\r\ndef\r\n' ]
console.log([append('abc\n', 'def')]);
//=> [ 'abc\ndef\n' ]
// uses os.EOL when a line ending is not found
console.log([append('abc', 'def')]);
//=> [ 'abc\ndef' ]
Append a string to another string ensuring to preserve line ending characters.
Params
str
{String}: String that will be used to check for an existing line ending. The suffix is appended to this.suffix
{String}: String that will be appended to the str.returns
{String}: Final StringExample
console.log([appendString('abc\r\n', 'def')]);
//=> [ 'abc\r\ndef\r\n' ]
console.log([appendString('abc\n', 'def')]);
//=> [ 'abc\ndef\n' ]
// uses os.EOL when a line ending is not found
console.log([appendString('abc', 'def')]);
//=> [ 'abc\ndef' ]
Append a buffer to another buffer ensuring to preserve line ending characters.
Params
buf
{Buffer}: Buffer that will be used to check for an existing line ending. The suffix is appended to this.suffix
{Buffer}: Buffer that will be appended to the buf.returns
{Buffer}: Final BufferExample
console.log([appendBuffer(new Buffer('abc\r\n'), new Buffer('def')).toString()]);
//=> [ 'abc\r\ndef\r\n' ]
console.log([appendBuffer(new Buffer('abc\n'), new Buffer('def')).toString()]);
//=> [ 'abc\ndef\n' ]
// uses os.EOL when a line ending is not found
console.log([appendBuffer(new Buffer('abc'), new Buffer('def')).toString()]);
//=> [ 'abc\ndef' ]
path.parse
, parses a filepath into an object. | homepagePull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Commits | Contributor |
---|---|
15 | jonschlinkert |
6 | doowb |
1 | phated |
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Jon Schlinkert
Copyright © 2017, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on August 01, 2017.
FAQs
File system utils for normalizing things like eol, encoding and BOM.
The npm package file-normalize receives a total of 65 weekly downloads. As such, file-normalize popularity was classified as not popular.
We found that file-normalize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.