{"name":"kslash","version":"2.2.0","description":"path tool","keywords":["slash","path","tool"],"main":"js/kslash.js","scripts":{"test":"mocha -c --require koffee/js/register ./coffee/test.coffee","watch":"onchange coffee/*.coffee -- npm run test"},"repository":{"type":"git","url":"git+https://github.com/monsterkodi/kslash.git"},"bugs":{"url":"https://github.com/monsterkodi/kslash/issues"},"homepage":"https://www.npmjs.com/package/kslash","author":{"name":"monsterkodi"},"license":"Unlicense","dependencies":{"fs-extra":"^10.0.0","isbinaryfile":"^4.0.8","textextensions":"^5.14.0","uuid":"^8.3.2","walkdir":"^0.4.1"},"devDependencies":{"chai":"^4.3.4","koffee":"^1.14.0","mocha":"^9.1.3","onchange":"^7.1.0"},"gitHead":"2a73305c4c65e5633f092fde3d336bc6737650c7","_id":"kslash@2.2.0","_nodeVersion":"17.0.1","_npmVersion":"8.1.0","dist":{"integrity":"sha512-PaR7GpnOhvp7s1wbErTDufanENhjHxmIQQGXlqlkRkWtclUGK/vurN941+YgnYYvH5B3AJtpoZbkZWn58CUDrA==","shasum":"a869f5d95e18831c62841822866bed9481ff0dd6","tarball":"http://registry-npm.ywwl.com/kslash/download/kslash-2.2.0.tgz","fileCount":4,"unpackedSize":92258,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDtJHd8Tvpu2J/AbfgSm7ghuiJcanX53nuGzzMY4vEnGAIhAMPWCgrL0zf8BXIRhleDMhaeEu3KfV162UKmUnLr1gZq"}],"size":23688,"noattachment":false,"key":"/kslash/-/kslash-2.2.0.tgz"},"_npmUser":{"name":"monsterkodi","email":"monsterkodi@gmx.net"},"directories":{},"maintainers":[{"name":"monsterkodi","email":"monsterkodi@gmx.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/kslash_2.2.0_1635459976881_0.6471279676517518"},"_hasShrinkwrap":false,"readme":"\n![kslash](kslash.png)\n\n**kslash** is a collection of path utilities.\n\nI use it as a replacement for [node's](https://nodejs.org/) [`path`](https://nodejs.org/dist/latest/docs/api/path.html) module.\nIt aims to deal with file paths in a platform independent way.\nMaybe it contains some tools of interest to you, even if you target only one platform.\n\n## resolve(p ...) \n\nApplies `unenv` and `untilde` before converting path into an absolute one.\nJoins all arguments before doing so.\n\nThis is the function I use the most and it usually resolves all my problems ☺️\n\n## path(p) \n\nNormalizes the path and converts backslashes to slashes.\n\n```coffeescript\nslash = require 'kslash'\nslash.path 'C:\\\\Back\\\\Slash'                           ▸ C:/Back/Slash\nslash.path 'C:\\\\Back\\\\Slash\\\\..\\\\To\\\\The\\\\..\\\\Future'  ▸ C:/Back/To/Future\n```\n\nWindows is capable of handling paths with forward slashes,\nthat's why all exported functions return 'slashed' paths -- except the next one -- which you can use in cases where it isn't :)\n\n## unslash(p)\n\nOn Windows it converts\n- slashes to backslashes\n- first dirname to a drive if it has only one letter\n\n```coffeescript\nslash.unslash '/c/test'         ▸ C:\\\\test\nslash.unslash 'D:/c/test'       ▸ D:\\\\c\\\\test\n```\n\n## dir(p)\n\n```coffeescript\np = '/dir/file.txt'\nslash.dir(p)                    ▸ /dir\n```\n\n## file(p)   \n\n```coffeescript\np = '/dir/file.txt'\nslash.file(p)                   ▸ file.txt\n```\n\n## base(p)   \n\n```coffeescript\np = '/dir/file.txt'\nslash.base(p)                   ▸ file\n```\n\n## ext(p) \n\n```coffeescript\np = '/dir/file.txt'\nslash.ext(p)                    ▸ txt\n```\n\n## removeExt(p)\n\n```coffeescript\np = '/dir/file.txt'\nslash.removeExt(p)              ▸ /dir/file\n```\n\n## swapExt(p, ext)\n\n```coffeescript\np = '/dir/file.txt'\nslash.swapExt(p, 'md')          ▸ /dir/file.md\nslash.swapExt(p, '.md')         ▸ /dir/file.md\n```\n\n## isRoot(p)\n\n```coffeescript\nslash.isRoot('C:\\\\')            ▸ true\nslash.isRoot('/')               ▸ true\n```\n\n## removeDrive(p)\n\n```coffeescript\np = 'C:\\\\dir\\\\file.txt'\nslash.removeDrive(p)            ▸ /dir/file.txt\n```\n## home()\n\n```coffeescript\nslash.home()                    ▸ C:/Users/kodi\n```\n\n## tilde(p) \n\n```coffeescript\np = 'C:/Users/kodi/file.txt'\nslash.tilde(p)                  ▸ ~/file.txt\n```\n\n## untilde(p) \n\n```coffeescript\np = '~/file.txt'\nslash.untilde(p)                ▸ C:/Users/kodi/file.txt\n```\n\n## unenv(p) \n\nReplaces `$...` with matching environment variables\n\n## split(p)\n\n```coffeescript\np = 'C:\\\\dir/file.txt'\nslash.split(p)                  ▸ ['C:', 'dir', 'file']\n```\n\n## splitExt(p) \n\n```coffeescript\np = 'C:\\\\dir/file.txt'\nslash.splitExt(p)               ▸ ['C:/dir/file', 'txt']\n```\n\n## splitDrive(p)\n\n```coffeescript\np = 'C:\\\\dir/file.txt'\nslash.splitDrive(p)             ▸ ['/dir/file.txt', 'c']\n```\n\n## splitFileLine(p) \n\n```coffeescript\np = '/dir/file.txt:12:3'\nslash.splitFileLine(p)          ▸ ['/dir/file.txt', 12, 3]\n```\n\n## splitFilePos(p) \n\n```coffeescript\np = '/dir/file.txt:12'\nslash.splitFilePos(p)           ▸ ['/dir/file.txt', [0,11]]\n```\n\n## removeLinePos(p)\n\n```coffeescript\np = '/dir/file.txt:12:3'\nslash.removeLinePos(p)          ▸ /dir/file.txt\n```\n\n## removeColumn(p) \n\n```coffeescript\np = '/dir/file.txt:12:3'\nslash.removeColumn(p)           ▸ /dir/file.txt:12\n```\n\n## joinFilePos(p, pos) \n\n```coffeescript\np = '/dir/file.txt:12'\nslash.joinFilePos(p, [2, 1])    ▸ /dir/file.txt:2:2\n```\n\n## joinFileLine(p, line, col)\n\n```coffeescript\np = '/dir/file.txt'\nslash.joinFileLine(p, 1, 2)     ▸ /dir/file.txt:1:2\n```\n\n## pathlist(p) \n\n```coffeescript\np = '/dir/file.txt'\nslash.pathlist(p)               ▸ ['/', '/dir', '/dir/file.txt']\n```\n\n```coffeescript\np = '$HOME/dir'\nslash.unenv(p)                  ▸ C:/Users/kodi/dir\n```\n\n## relative(p, to) \n\n```coffeescript\np = 'C:/test/some/path.txt' \nto ='C:/test/some/other/path'\nslash.relative(p,to)            ▸ ../../path.txt\n```\n\n## samePath(p, q) \n\n`Resolves` p and q and compares the results.\n\n## encode(p) \n\nEncodes p for use as an URL.\n\n```coffeescript\np = '/dir/a # b' \nslash.encode(p)                 ▸ /dir/a%20%23%20b\n```\n\n## fileUrl(p) \n\nEncodes p and prefixes it with 'file://'\n\n```coffeescript\np = '/dir/a # b' \nslash.fileUrl(p)                ▸ file:///dir/a%20%23%20b\n```\n\n## tmpfile(ext)\n\nReturns a joined path of os.tmpdir and an [uuid](https://www.npmjs.com/package/uuid)\n\n## pkg(p)\n\nSearches backwards in `pathlist` of p for a package.json and returns the containing folder, if one is found.\n\n## git(p) \n\nSame as `pkg`, just looking for `.git` directory instead.\n\n## touch(p)\n\nLike the unix command, creates intermediate directories if they don't exist.\n\n## list(p,opt,cb) listdir(p,opt,cb)\n\nCalls back with a list of info objects for items in directory p.\nA small wrapper around the `walkdir` package.\n\n## exists(p, cb)\n\nReturns [stat](https://nodejs.org/dist/latest/docs/api/fs.html#fs_class_fs_stats) of path p if it exists, null otherwise.\n\nThe callback is optional.\nIf provided, the test is executed asynchronously and the callback will be called with the result\n\n```coffeescript\nslash.exists p, (stat) -> if stat then # ...\n```\n\nThe same is true for the following functions that have a callback argument:\n\n## isDir(p, cb) dirExists(p, cb)\n\nReturns [stat](https://nodejs.org/dist/latest/docs/api/fs.html#fs_class_fs_stats) of path p if it is a directory, null otherwise.\n\n## isFile(p, cb) fileExists(p, cb)\n\nReturns [stat](https://nodejs.org/dist/latest/docs/api/fs.html#fs_class_fs_stats) of path p if it is a file, null otherwise.\n\n## isWritable(p, cb)\n\nReturns true if p is writable.\n\n## isText(p)\n\nReturns true if p is a textfile.\n\n## readText(p, cb)\n\nReturns content of p as an utf8 string. \nReturns an empty string, if p doesn't exist or isn't readable.\n\n## unused(p, cb)\n\nReturns p if p doesn't exist. \nOtherwise, returns a path with a number attached such that the path doesn't exist.\n\n## sanitize(p)\n\nRemoves leading and trailing newlines from path p.\n\n## win()\n\nReturns true if path.sep is '\\\\'. \n\n## isAbsolute(p) isRelative(p) normalize(p) dirname(p) extname(p) basename(p, ext) parse(p) join()\n\nSame as the functions of the `path` module but p is `sanitized` and `slashed` first.\n\n## Doesn't throw\n\nAll functions return an empty string or null if the provided path is an empty string, null or undefined.\nThe same is true, if an underlying function call throws an error.\n\nIf this is too lax for your taste, or you want to debug your code, you can redefine the function `slash.error`:\n\n```coffeescript\nslash.error = (msg) -> # throw or log or something else ...\n```\n\n[![npm package][npm-image]][npm-url] \n[![Build Status][travis-image]][travis-url] \n[![downloads][downloads-image]][downloads-url] \n\n[npm-image]:https://img.shields.io/npm/v/kslash.svg\n[npm-url]:http://npmjs.org/package/kslash\n[travis-image]:https://travis-ci.org/monsterkodi/kslash.svg?branch=master\n[travis-url]:https://travis-ci.org/monsterkodi/kslash\n[downloads-image]:https://img.shields.io/npm/dm/kslash.svg\n[downloads-url]:https://www.npmtrends.com/kslash\n","publish_time":1635459977026,"_cnpm_publish_time":1635459977026,"dist-tags":{"latest":"2.7.0"}}