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

context-finder

v1.1.1

Published

Read a file containing a list of context blocks and extract the contexts you want with a simple line

Downloads

25

Readme


Context Finder is simple and easy to use. It extracts contexts from (usually) configuration files. The main use case is extracting contexts from Asterisk configuration files.

Refer to the example here

Context Finder is available for NPM/Node and Deno.

Contents

Use Case

You have a file that holds context blocks. That file might look like this:

[user-1]
name = Edward
language = en

[user-2]
name = John
language = us

[admin-1-1]
name = Admin Edward

[admin-1-2]
name = Admin John

[admin-2]
name = Admin

You want to extract all admin-1 contexts. In a single command you can pull that into a resulting file:

[admin-1-1]
name = Admin Edward

[admin-1-2]
name = Admin John

This is where Content Finder comes in.

Requirements

  • If using NPM
    • NodeJS
      • apt install nodejs
    • NPM
      • apt install npm
  • If using Deno
    • Deno

NPM: As a Script

  • Install the package from the NPM library

    npm i --save context-finder in your project root, or where your configuration files reside.

    You will need to add node_modules and package-lock.json to your gitignore file, then track package.json

  • Require the package

// my-node-script.js
const contextFinder = require('context-finder')
  • Gather your Variables and Run
const contextsToFind = ['version-1.', 'version-4.']
const fileToRead = 'all-contexts.txt' // this file must exist
const fileToWrite = 'some-contexts.txt'

contextFinder(contextsToFind, fileToRead, fileToWrite)

Node: CLI

  • Navigate to a directory of your choice

cd ~/projects

  • Pull down the repository

git clone https://www.github.com/ebebbington/context-finder.git

  • Install dependencies

cd conteext-finder && npm i

  • Run

node index.js <file to read> <file to write to> <context title 1> <context-title 2> ...

Deno: As a Script

  • Import the module
import { contextFinder } from "https://deno.land/x/[email protected]/mod.ts";
  • Gather your data and run
const contextsToFind = ['version-1.', 'version-4.']
const fileToRead = 'all-contexts.txt' // this file must exist
const fileToWrite = 'some-contexts.txt'

contextFinder(contextsToFind, fileToRead, fileToWrite)

Deno: CLI

deno run --allow-read --allow-write https://deno.land/x/[email protected]/mod.ts <file to read> <file to write to> <context title 1> <context-title 2> ...

Built With

  • NodeJS - Runtime Environment
  • Deno - Runtime Environment

License

This project is licensed under the MIT License - see the LICENSE.txt file for details