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

@disane/nextract

v1.1.0

Published

Tool to extract text out of specific filetypes by regex

Downloads

74

Readme

@disane/nextract

Just a random tool to exctract text by regex out of specific files

This is my first npm package to extract text by a regex out of a folder and genererates different output formats like

Usage

    ===================================================
     ______   ___   _______  _______  __    _  _______
    |      | |   | |       ||   _   ||  |  | ||       |
    |  _    ||   | |  _____||  |_|  ||   |_| ||    ___|
    | | |   ||   | | |_____ |       ||       ||   |___
    | |_|   ||   | |_____  ||       ||  _    ||    ___|
    |       ||   |  _____| ||   _   || | |   ||   |___
    |______| |___| |_______||__| |__||_|  |__||_______|

    // Package: @disane/nextract
    Tool to extract text out of specific filetypes by regex

    // HP:      https://gitlab.com/Disane87/nextract/#readme
    ===================================================

Usage: 
    nextract <command> [options]

Example:
    nextract search -f -p  "C:/temp" 

Commands:
    search              Searches files by regex in all file types in path

Options:
  --version             Show version number                            [boolean]
  --help                Show help                                      [boolean]
  -p, --path            Path to search in                               [string]
  -s, --searchrequests  Patterns to search in path                       [array]
  -f, --fullpath        Outputs the full path of found files
                                                      [boolean] [default: false]
  -o, --output          Outputs the full path of found files
                          [choices: "console", "json", "html", "file"] [default: "file"]

Installing

npm install @disane/nextract -g or locally npm install @disane/nextract --save-dev

Using it via cli

nextract search -f -p  "C:/temp" -o "console"

Output:

Output mode: console
SearchPath:  C:/temp
Searching for RegEx '(?<=\{\{).*?(?=\ *\|\ *translate)' in '.html'. Please wait.
\test.html
⟹       [1:2] TEST (string)

Content of test file:

<div>{{ 'TEST' | translate }}</div>

Output as html file (default browser will be opened)

nextract search -f -p  "C:/temp" -o "html"

html overview

Using it as a module in typescript/node

With output as file

const nextract = require('@disane/nextract');

// import * as nextract from '@disane/nextract';
nextract.main({p: "C:/temp", o: 'file'});

test = nextract.getResultsFromFile();
console.log(test);

With output as json

extract.main({p: "C:/temp"}).then((results)=> {
    console.log(results);
});

With custom search patterns


const searchRequests = [
    { searchPattern: '(flying)', fileType: '.txt'}
];

// import * from '@disane/translation-extract';
extract.main({p: "c:/temp", s: searchRequests}).then((results)=> {
    console.log(results);
});

Output as html file (default browser will be opened)

const extract = require('@disane/nextract');

const searchRequests = [
    { searchPattern: '(flying)', fileType: '.txt'}
];

// import * from '@disane/translation-extract';
extract.main({p: "c:/temp", s: searchRequests, o: 'html'});

html overview

General output format

Results are always returned as an array of Type SearchRequests. For every search request, there will be a returned object of the following type:

export interface SearchRequests {
    searchPattern: string;
    fileType: string;
    results?: FoundFiles[];
    folder?: string;
}
export interface FoundFiles {
    fileName: string;
    occurances: Position[];
}

export interface Position {
    lineNumber: number;
    rowNumber: number;
    line?: string;
    translations?: Translation[];
}
export interface Translation {
    language?: string;
    placeholder: string;
    translation?: string;
    placeholderType: 'code' | 'string';
}

License

MIT © Marco Franke