npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

path-copilot

v1.0.0-Beta

Published

A rich and colorful toolkit about Path.

Downloads

12

Readme

path-copilot

A toolkit for path

Usage

npm i path-copilot

path-copilot - v1.0.0-Beta

path-copilot - v1.0.0-Beta

Table of contents

Functions

Functions

isAbsolute

isAbsolute(path): boolean

Determine whether the given path string is an absolute path.

Since

1.0.0

Example

isAbsolute('/')      // true
isAbsolute('/path')  // true
isAbsolute('C:\\path')  // true
isAbsolute('\\path')  // true
isAbsolute('https://example.com')   // true
isAbsolute('ftp://example.com')     // true
isAbsolute('relative/path')  // false

Parameters

| Name | Type | Description | | :------ | :------ | :------ | | path | string | The path string to be determined. |

Returns

boolean

True if it's an absolute path, false otherwise.

Defined in

isAbsolute.ts:18


join

join(...paths): string

Combines an array of path segments into a single path string, with forward slashes (/) as separators.

Since

1.0.0

Example

const path = join('foo', 'bar', 'baz'); // path == 'foo/bar/baz'
const path2 = join('foo/', '/bar/', '/baz/'); // path2 == 'foo/bar/baz'

Parameters

| Name | Type | Description | | :------ | :------ | :------ | | ...paths | string[] | An array of path segments to join. |

Returns

string

A combined path string.

Defined in

join.ts:13


normalize

normalize(path): string

Normalize a file system path by removing any unnecessary "." and ".." segments and resolving any directory separators to match the host operating system.

Example

const path = '/users/john/../jane/./documents/';
const normalizedPath = normalize(path); // "/users/jane/documents/"

Since

1.0.0

Parameters

| Name | Type | Description | | :------ | :------ | :------ | | path | string | The file system path to be normalized. |

Returns

string

The normalized path.

Defined in

normalize.ts:17


parseUrl

parseUrl(url): Object

Parses the query and hash parameters of the specified URL string.

Example

// Basic usage
const url = 'http://example.com/path/to/page?a=1&b=2#section1';
const { query, hash } = parseUrl(url);
console.log(query); // { a: '1', b: '2' }
console.log(hash); // { section1: '' }

// Query and hash without value
const url2 = 'http://example.com/path/to/page?a&b#c';
const { query: query2, hash: hash2 } = parseUrl(url2);
console.log(query2); // { a: '', b: '' }
console.log(hash2); // { c: '' }

// Query with array value
const url3 = 'http://example.com/path/to/page?color=red&color=green&color=blue';
const { query: query3, hash: hash3 } = parseUrl(url3);
console.log(query3); // { color: ['red', 'green', 'blue'] }
console.log(hash3); // {}

Since

1.0.0

Parameters

| Name | Type | Description | | :------ | :------ | :------ | | url | string | The URL string to parse. |

Returns

Object

An object containing the query and hash parameters of the URL.

| Name | Type | | :------ | :------ | | hash | Record<string, string | string[]> | | query | Record<string, string | string[]> |

Defined in

parseUrl.ts:64