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

@igor.dvlpr/open-resource

v1.1.0

Published

๐Ÿ“‚ Opens a given resource (URL, file, etc.) via the default OS handler. ๐Ÿ”Ž

Readme

๐Ÿ“ƒ Table of contents

๐Ÿค– Features

  • ๐Ÿ’ป cross-platform, for Windows, macOS, Linux and Android using:
  • โณ both sync and async methods
  • ๐Ÿ“ƒ supports passing of arguments

๐Ÿ•ต๐Ÿผ Usage

Install it by executing:

npm i '@igor.dvlpr/open-resource'

๐Ÿคน๐Ÿผ API

An options object can be passed to the open() functions, it being described by the interface IOptions as follows:

IOptions

interface IOptions {
  args?: string[]
  msShell?: 'cmd' | 'powershell'
}

args - The arguments to pass to the command.

msShell - The shell to use for the command execution. Only available on Windows.


openSync(resource: string, options?: IOptions): void

Opens a specified resource synchronously using the appropriate command for the current platform.

resource - The resource to be opened, a path, URL, etc. Must be a non-empty string.

options - Optional configuration for the command execution.

Throws an error if no resource is specified, if the arguments are invalid, or an error occurs during execution.


open(resource: string, options?: IOptions): Promise<void>

Opens a specified resource asynchronously using the appropriate command for the current platform.

resource - The resource to be opened, a path, URL, etc. Must be a non-empty string.

options - Optional configuration for the command execution.

Throws an error if no resource is specified, if the arguments are invalid, or an error occurs during execution.


โœจ Examples

example.mts

import { openSync } from '@igor.dvlpr/open-resource'

openSync('https://igorskyflyer.me') // will open the default browser and navigate to the site

openSync('D:\\Data\\file.txt') // will open the text file in the default text viewer/editor

๐Ÿ“ Changelog

๐Ÿ“‘ The changelog is available here: CHANGELOG.md.


๐Ÿชช License

Licensed under the MIT license which is available here, MIT license.


๐Ÿงฌ Related

@igor.dvlpr/registry-apppaths

๐Ÿช€ A Node.js module for reading the AppPaths registry key on Windows. Useful for retrieving applications that can be launched from the command prompt. ๐Ÿ—ƒ

@igor.dvlpr/regkeys

๐Ÿ“š An npm package for fetching Windows registry keys. ๐Ÿ—

@igor.dvlpr/upath

๐ŸŽ Provides a universal way of formatting file-paths in Unix-like and Windows operating systems as an alternative to the built-in path.normalize(). ๐Ÿงฌ

@igor.dvlpr/windows-packages

๐Ÿ’ป A Node.js module for reading the Packages registry key on Windows 10+. Useful for retrieving Windows 10+ installed Store applications. ๐Ÿ“ฆ

@igor.dvlpr/scrollend-polyfill

๐Ÿ›ด A performant and light (< 1.5KB) JavaScript polyfill for the scrollend Event. โ›ธ๏ธ


๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป Author

Created by Igor Dimitrijeviฤ‡ (@igorskyflyer).