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 🙏

© 2026 – Pkg Stats / Ryan Hefner

seo_defects_sb

v1.0.1

Published

seo defects detector assignment

Readme

SEO Defect Parser

Build Status Coverage Status

NPM

A seo defect parser. The parser could detect the seo defect rule.

Installation

npm install seo_defects_sb

Example

  • Check the file test.html by the default rule, and output to STDOut
const seoDefects = require('seo_defects_sb');

const parser = new seoDefects.SeoParser();

parser.init(
    seoDefects.fileReadableStream('test.html'),
    seoDefects.consoleWritableStream()
);

parser.parse(function() {
    console.log('parse end');
})

API Readable/Writable Stream

fileReadableStream(filename)

/**
 * Create readable file stream
 * @param {string} filename input file name
 * @return {ReadableStream} stream
 */

consoleReadableStream()

/**
 * Create stdin stream
 * @return {ReadableStream} process stdin
 */

fileWritableStream(filename)

/**
 * Create writable file stream
 * @param {string} filename output file name
 * @return {WritableStream} stream
 */

consoleWritableStream()

/**
 * Create stdout stream
 * @return {WritableStream} process stdin
 */

SeoParser

SeoParser.init(input, output, rules=null)

/**
 * init input and output streams, defect rules
 * @param {readableStream} input
 * @param {WritableStream} output
 * @param {Rule} rules, if null, check by default rules
 * @throws {SeoParserInputError} invalid typeof streams
 */

SeoParser.parse(completeCb=null)

/**
 * Start to parse
 * @param {function} completeCb complete callback
 */

Default rules:

  1. Detect if any <img /> tag without alt attribute(imgWithoutAlt())
  2. Detect if any <a /> tag without rel attribute(aWithoutRel())
  3. In <head> tag
  • Detect if header doesn’t have <title> tag(inHeadNoTitle())
  • Detect if header doesn’t have <meta name=“descriptions” … /> tag(inHeadMetaNameIsDescriptions())
  • Detect if header doesn’t have <meta name=“keywords” … /> tag(inHeadMetaNameIsKeywords())
  1. Detect if there’re more than {num} <strong> tag in HTML(strongGreaterNum(num))
  2. Detect if a HTML have more than one <H1> tag(h1Unique())

Rule

A object decides whether to write the error message to the writable stream.

Rule(condition)

/**
 * Constructor
* @param {Cond} condition, the condition to be checked
*/

Rule.equal(val), Rule.less(val), Rule.greater(val)

/**
 * Check the num of counts which satify the condition
 * @param {number} val
 * @return {Rule} rule object
 */

Rule.msg(val)

/**
 * Set error message
 * @param {string} val, error message to be written
 */

Cond

Cond.tag(tag)

/**
 * Set html tag, the condition want to check
 * @param {string} tag
 * @return {Cond} condition object
 */

Cond.attrib(name)

/**
 * Set attribute, the condition want to check
 * @param {string} name
 * @return {Cond} condition object
 */

Cond.exist(val=null), Cond.notExist(val=null)

/**
 * Set attribute value(default null), the condition want to check
 * @param {string} val, attribute value
 * @return {Cond} condition object
 */

Cond.has(cond)

/**
 * A nested condition pattern
 * @param {Cond} cond
 * @return {Cond} condition  object
 */

User-defined Rule

  • Detect if any <meta /> tag with name attribute, and its value equal to 'test' exists.
let condObj = new Cond();
condObj = condObj.tag('meta').attrib('name').exist('test');
const rule = new Rule(condObj).greater(0);
  • In <p> tag, detect if <span> tag with style attribute does not exists.
const condObj = new Cond();
let parentCondObj = new Cond();
parentCondObj = parentCondObj.tag('p').has(
    condObj.tag('span').attrib('style').exist());
const rule = new Rule(parentCondObj).equal(0);