Socket
Book a DemoInstallSign in
Socket

micro-lines

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

micro-lines

This service does one thing, breaks up an HTML document into a JSON array of lines. Allowing you to count or find information in a document.

latest
Source
npmnpm
Version
1.1.3
Version published
Maintainers
1
Created
Source

lines

This service does one thing, breaks up an HTML document into a JSON array of lines. Allowing you to count or find information in a document.

Setup

  • Clone this repo
  • cd lists (go into this repo's folder)
  • npm install
  • npm start

That's it (🎉), the local lists server is now running at localhost:3333!

Usage

Getting all lines

Send a GET request to the service with the absolute path of the document you want to split lines on.

like: https://servicedomain.com/https://htmlinquestion.com/file.html

example:

<script>
  fetch('servicedomain.com/' + window.location.href)
    .then(response => response.json())
    .then(data => console.log(data.lines))
    .catch(err => console.log('Something went wrong:', err));
</script>

The response will look like:

{
  "lines": [
    "<html>",
    "  <head>",
    //...
  ]
}

Get lines by RegExp

If you want to search for lines by regex you can use the ?_regexp param.

like: https://servicedomain.com/https://htmlinquestion.com/file.html?_regexp=/something/i

which returns:

{
  "matches": [
    {
      // raw matching line
      line: "   something happened and I didn't know it at the time",
      // index of the line as it lives inside the document
      index: 50
    },
    {
      line: "   something else happened",
      index: 124
    },
    // ... and so on for all matches
  ]
}

Note there is a difference between responses with ?_regexp and without it. So don't say I didn't warn you ;)

License

Copyright ©️ 2017 Sean Roberts, licensed under the MIT License. See LICENSE.md for more information.

FAQs

Package last updated on 27 Jan 2017

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