Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kslash

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kslash

path tool

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
78
increased by6.85%
Maintainers
1
Weekly downloads
 
Created
Source

kslash

kslash is a collection of path utilities.

path(p)

Normalizes the path on all platforms. Converts backslashes to slashes on Windows.

slash = require 'kslash'
slash.path 'C:\\Back\\Slash'                           ▸ C:/Back/Slash
slash.path 'C:\\Back\\Slash\\..\\To\\The\\..\\Future'  ▸ C:/Back/To/Future

Windows is capable of handling paths with forward slashes, that's why all exported functions return 'slashed' paths -- except the next one -- which you can use in cases where it isn't :)

unslash(p)

Normalizes the path on all platforms. On Windows it converts

  • slashes to backslashes
  • first dirname to a drive letter if it has only one letter
slash.unslash '/c/test'                                ▸ C:\\test

utilities

Here comes a list of the provided functions. I plan to document these as well, but for now you have to peek at the sources 🤢 Drop me a note in the issues if you want me to prioritize any of them.

dir(p)

file(p)

base(p)

ext(p)

removeExt(p)

swapExt(p, ext)

isRoot(p)

removeDrive(p)

home()

tilde(p)

untilde(p)

userData()

split(p)

splitExt(p)

splitDrive(p)

splitFileLine(p)

splitFilePos(p)

removeLinePos(p)

removeColumn(p)

joinFilePos(p, pos)

joinFileLine(p, line, col)

pathlist(p)

isAbsolute(p)

isRelative(p)

normalize(p)

sanitize(p)

parse(p)

unenv(p)

resolve(p)

relative(p, to)

fileUrl(p)

samePath(p, q)

win()

join()

dirname(p)

extname(p)

basename(p, ext)

escape(p)

encode(p)

pkg(p)

git(p)

touch(p)

exists(p, cb)

isDir(p, cb)

isFile(p, cb)

fileExists(p, cb)

dirExists(p, cb)

isWritable(p, cb)

isText(p)

readText(p, cb)

Notes

  • Most functions return an empty string if the provided path doesn't exist.
  • Callbacks are optional. If provided, functionality will be executed synchonously and callback will be called with result or empty string on failure.

Keywords

FAQs

Package last updated on 04 Jun 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc