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

html-version

v1.1.2

Published

parse and modify html versions according to the html version spec

Downloads

40

Readme

html-version

parse and modify html file versions according to the html version spec

example

parse

var fs = require('fs')
var versions = require('html-version')

fs.readFile(__dirname + '/page.html', function (err, src) {
  console.log(versions.parse(src))
})

output:

{ integrity: 
   { 'https://example.com/versions/1.0.0.html': [ 'sha256-mPjSxFzbBSy+LyCVyylIf5E/7zswbvsL4D/qxCAqrjY' ],
     'https://example.com/versions/1.0.1.html': [ 'sha256-Qra3bKdpoprvRqkTF96gWOa0dPkA8MHYxOJqVsvkzIY=' ],
     'https://example.com/versions/1.1.0.html': [ 'sha256-9VGwnCJuLbwo/N+TL1Ia9whqP8kVwEO8K0IFTUQk19o=' ] },
  version: '1.2.0',
  versions: 
   { '1.0.0': 
      [ 'https://example.com/versions/1.0.0.html',
        'magnet:?xt=urn:btih:4822271aa656ba6913a14edb117d3c4dc50f1209' ],
     '1.0.1': 
      [ 'https://example.com/versions/1.0.1.html',
        'ipfs:QmNcojAWDNwf1RZsPsG2ABvK4FVs7yq4iwSrKaMdPwV3Sh',
        'magnet:?xt=urn:btih:d0320ebba035cc86526baae771da14912895e113' ],
     '1.1.0': 
      [ 'https://example.com/versions/1.1.0.html',
        'ipfs:QmWMey8Dd1ZH9XWRP3d7N1oSoL35uou1GSMpBwt4UahFSD' ] },
  signature: [ 'https://example.com/versions/1.2.0.html.sig' ],
  latest: 
   [ 'https://example.com/versions/latest.html',
     'ipns:QmWJ9zRgvEvdzBPm1pshDqqFKqMXRJoHDQ4nuocHYS2REk',
     'magnet:?xt=urn:btih:4a533d47ec9c7d95b1ad75f576cffc641853b750' ],
  predecessor: 
   [ 'https://example.com/versions/1.1.0.html',
     'ipfs:QmWMey8Dd1ZH9XWRP3d7N1oSoL35uou1GSMpBwt4UahFSD' ] }

upgrade

var fs = require('fs')
var versions = require('html-version')

var prev = fs.readFileSync(__dirname + '/page.html')
var src = fs.readFileSync(__dirname + '/src.html')
var loc = [
  'https://example.com/versions/1.2.0.html',
  'ipfs:QmSguVEXZRRtDCRm3XGjvTQNnLHWkgowoFJ9jpCp5kEMEB'
]
console.log(versions.update(src, loc, versions.parse(prev)))

output:

<html>
  <head>
    <meta name="version" content="1.2.1">
    <link rel="version" href="https://example.com/versions/1.0.0.html" version="1.0.0" integrity="sha256-mPjSxFzbBSy+LyCVyylIf5E/7zswbvsL4D/qxCAqrjY">
    <link rel="version" href="magnet:?xt=urn:btih:4822271aa656ba6913a14edb117d3c4dc50f1209" version="1.0.0">
    <link rel="version" href="https://example.com/versions/1.0.1.html" version="1.0.1" integrity="sha256-Qra3bKdpoprvRqkTF96gWOa0dPkA8MHYxOJqVsvkzIY=">
    <link rel="version" href="ipfs:QmNcojAWDNwf1RZsPsG2ABvK4FVs7yq4iwSrKaMdPwV3Sh" version="1.0.1">
    <link rel="version" href="magnet:?xt=urn:btih:d0320ebba035cc86526baae771da14912895e113" version="1.0.1">
    <link rel="version" href="https://example.com/versions/1.1.0.html" version="1.1.0" integrity="sha256-9VGwnCJuLbwo/N+TL1Ia9whqP8kVwEO8K0IFTUQk19o=">
    <link rel="version" href="ipfs:QmWMey8Dd1ZH9XWRP3d7N1oSoL35uou1GSMpBwt4UahFSD" version="1.1.0">
    <link rel="version" href="https://example.com/versions/1.2.0.html" version="1.2.0">
    <link rel="version" href="ipfs:QmSguVEXZRRtDCRm3XGjvTQNnLHWkgowoFJ9jpCp5kEMEB" version="1.2.0">
    <link rel="latest-version" href="https://example.com/versions/latest.html">
    <link rel="latest-version" href="ipns:QmWJ9zRgvEvdzBPm1pshDqqFKqMXRJoHDQ4nuocHYS2REk">
    <link rel="latest-version" href="magnet:?xt=urn:btih:4a533d47ec9c7d95b1ad75f576cffc641853b750">
    <link rel="predecessor-version" href="https://example.com/versions/1.2.0.html">
    <link rel="predecessor-version" href="ipfs:QmSguVEXZRRtDCRm3XGjvTQNnLHWkgowoFJ9jpCp5kEMEB">
  </head>
  <body>
    whatever
  </body>
</html>

api

var versions = require('html-version')

var info = versions.parse(html)

Parse a string of html into an object info:

  • info.version - the <meta name="version"> contents
  • info.versions - an object mapping semver version strings to arrays of URLs
  • info.integrity - an object mapping URLs to arrays of integrity strings
  • info.signature - an array of signature URLs
  • info.latest - an array of latest version URLs
  • info.predecessor - an array of predecessor version URLs

var html = versions.meta(info)

Return meta and link tags in an html string for info, a parsed version object.

var html = versions.update(src, loc, prevInfo)

Update src with new meta and link tags that add to the previous version metadata.

Return a string of html for a current html string src, the location of the previous document as an array of URLs loc, and prevInfo, the parsed version info for the previous html.

thanks

Thanks to blockai for sponsoring this project.

license

MIT