JSPM

slashf

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q14733F
  • License MIT

Forward-slash normalization of function results via composition

Package Exports

  • slashf

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (slashf) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

slashf: forward-slash normalization via composition

This package provides a slashf(f) function used to normalize the output of any wrapped function, in the situation in which a string is returned and contains backslashes.

Example usage:

import { slashf } from 'slashf';

function myPath(myFileName) {
    return '\\my\\path\\' + myFileName;
}

const myPathNorm = slashf(myPath);

console.log(myPathNorm('myfile.txt'));

This snippet would print:

'/my/path/myfile.txt'

API

slashf(f)

Wraps a function, normalizes its output - if it's a string - and returns it.

slash(x)

Normalizes x by replacing all the slashes with forward slashes and returns it. If x is not a string it's returned as is.

Example

slash('/a\\b/c') == '/a/b/c';
slash([1, 2, 3]) == [1, 2, 3];

License

This package is distributed under the MIT license. See the LICENSE file for further information.