🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

hand-node-seo

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hand-node-seo

seo package demo for

latest
Source
npmnpm
Version
1.0.7
Version published
Maintainers
1
Created
Source

It's a demo, do not use in production

npm install hand-node-seo --save

const RuleEngineClass = require('hand-node-seo').RuleEngineClass;

input: 1 if you have a html file, you can read it as string. The string could be an argument when create instance.

const htmlStr = fs.readFileSync('test/test.html').toString('utf-8');
const ruleEngine = new RuleEngineClass(htmlStr);

you don't need any callback function if you create instance this way, you can use the methods directly, for example: const ruleEngine = new RuleEngineClass(htmlStr) .addCustomRule(customRuleB) .runH1TagDetect() .runStrongTagDetect(1) .runTitleTagInHeadDetect() .addDetectMetaName('hands') .runMetaNameDetect() ...

2 Could be a ReadStream, there are two events 'readEnd','error' with property 'readStreamEvent' while your input is ReadStream. You will get an engine instance while readEnd happend, for example:

const ruleEngine = new RuleEngineClass();
ruleEngine.loadWithStream(request.get('https://www.google.com'));
or
ruleEngine.loadWithFile('test/test.html');

ruleEngine.readStreamEvent.on('readEnd', engine => {
	engine
		.....
});
ruleEngine.readStreamEvent.on('error', err => console.error(err));

As requirements, there are methods with the instance.

Custom rules

The developer can make their own rules via addCustomRule(rule) method. The custom rules are formatted. For example:

const customRuleA = {
	ruleName: 'customA',
	execReg: function (html) {
		const res = [];
		if (!html || html.length === 0) {
			res.push(`Custom A detect <h2>, 0 founded`);
			return res;
		}
		let r = /<h2>/ig;
		const arr = html.match(r);
		if (!arr || arr.length === 0) {
			res.push(`Custom A detect <h2>, 0 founded`);
			return res;
		}
		res.push(`Custom A detect <h2>, ${arr.length} founded`);
		return res;
	}
};

1. The ruleName must be unique.
2. The function must return an array of string

And then, you can use method runCustomDetect() for running custom rules

ruleEngine
	.addCustomRule(customRuleA)
	.runCustomDetect()

Output can be:

  • A file, no returns, just save as a file toFile(filePath)

  • A writeStream, return a node writeStream object toFileStream(filePath, encoding)

  • console, no returns, just output to console

Keywords

seo

FAQs

Package last updated on 20 Jun 2018

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