🚀 Launch Week Day 3:Introducing Supply Chain Attack Campaigns Tracking.Learn More →
Socket
Book a DemoInstallSign in
Socket

assert-path

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assert-path

Extends node's assert module with methods for testing filepaths.

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

assert-path NPM version

Extends node's assert module with methods for testing filepaths.

Install

Install with npm

$ npm i assert-path --save

Usage

var assert = require('assert');
require('assert-path')(assert);

API

assert.dirname

Returns true if path.dirname of filepath a equals filepath b.

assert.dirname(a, b);

Example

assert.dirname('a/b/c.js', 'a/b/c');
//=> true

assert.basename

Returns true if path.basename of filepath a equals filepath b.

assert.basename(a, b);

Example

assert.basename('a/b/ccc.js', 'ccc.js');
//=> true

assert.filename

Returns true if path.filename of filepath a equals filepath b.

assert.filename(a, b);

Example

assert.filename('a/b/ccc.js', 'ccc');
//=> true

assert.extname

Returns true if path.extname of filepath a equals filepath b.

assert.extname(a, b);

Example

assert.extname('a/b/c.js', '.js');
//=> true

assert.path

Returns true if filepath a equals filepath b.

assert.path(a, b);

Example

assert.path('a/b/c.js', 'a/b/c.js');
//=> true

assert.absolute

Returns true if path.resolve(a) equals path.resolve(b).

assert.absolute(a, b);

Example

assert.absolute('a/b/c.js', 'a/b/c.js');
//=> true

assert.segments

Returns true if the last nth segments of a equals the last nth segments of b. For example, the last 2 segments of foo/bar/baz/qux.md would be baz/qux.md.

assert.segments(a, b, 2);

Example

// b/c.js === 'b/c.js'
assert.segments('a/b/c.js', 'a/b/c.js');
//=> true

assert.lastSegments

Returns true if the last nth segments of a equals b.

assert.lastSegments(a, b, 2);

Example

assert.lastSegments('a/b/c/d/e.js', 'd/e.js', 2);
//=> true

assert.isAbsolute

Returns true if a filepath is absolute.

assert.isAbsolute(filepath);

Example

assert.isAbsolute('a/b/c.js');
//=> false

assert.isAbsolute(path.resolve('a/b/c.js'));
//=> false

assert.isRelative

Returns true if path.resolve(a) equals path.resolve(b).

assert.isRelative(filepath);

Example

assert.isRelative('a/b/c.js');
//=> true
assert.isRelative(path.resolve('a/b/c.js'));
//=> false
  • is-absolute: Return true if a file path is absolute. | homepage
  • is-relative: Returns true if the path appears to be relative. | homepage
  • normalize-path: Normalize file path slashes to be unix-like forward slashes. Also condenses repeat slashes to a… more | homepage
  • relative: Get the relative filepath from path A to path B. Calculates from file-to-directory, file-to-file, directory-to-file,… more | homepage

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.

This file was generated by verb-cli on November 08, 2015.

Keywords

assert

FAQs

Package last updated on 08 Nov 2015

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