Socket
Socket
Sign inDemoInstall

yaspeller

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yaspeller - npm Package Compare versions

Comparing version 3.2.0 to 3.3.0

lib/eyo.js

12

CHANGELOG.md
# Changelog
# 3.2.0
## 3.3.0
- Glob patterns for Windows
- Updated deps in package.json
## 3.2.0
- File extension with multiple dots #66, #67 @levonet
# 3.1.0
## 3.1.0
- Remove acute accent, shy and other symbols #65

@@ -24,3 +28,3 @@ - Updated deps in package.json

## 2.9.0
## 2.9.0
- Ability to ignore the text using regular expressions (`--ignore-text` for CLI or `ignoreText` for `.yaspellerrc`)

@@ -48,7 +52,5 @@ - Updated deps in package.json

## 2.5.1
- Updated deps in package.json
## 2.5.0

@@ -55,0 +57,0 @@ - Replace npm module `eyo` to `eyo-kernel`

@@ -11,2 +11,3 @@ 'use strict';

const yaspeller = require('./yaspeller');
const glob = require('glob');

@@ -39,2 +40,24 @@ function hasData(err, data) {

/**
* Expand glob arguments.
*
* @param {string[]} args
* @return {string[]}
*/
expandGlobArgs(args) {
let result = [];
for (const value of args) {
if (utils.isUrl(value)) {
result.push(value);
} else {
const files = glob.sync(value);
if (files) {
result = result.concat(files);
}
}
}
return result;
},
/**
* Prepare tasks for resources.

@@ -47,55 +70,14 @@ *

forResources(resources, settings) {
const tasks = [];
resources.forEach(function(resource) {
tasks.push(function(cb) {
const subTasks = [];
if (utils.isUrl(resource)) {
if (utils.isSitemap(resource)) {
yaspeller.checkSitemap(resource, function() {
cb();
}, settings, onResource);
} else {
yaspeller.checkUrl(resource, function(err, data, originalText) {
onResource(err, data, originalText);
cb();
}, settings);
}
return this.expandGlobArgs(resources).map(resource => callback => {
if (utils.isUrl(resource)) {
this.forUrl(resource, settings, callback);
} else {
if (fs.existsSync(resource)) {
this.forFiles(resource, settings, callback);
} else {
if (fs.existsSync(resource)) {
if (utils.isDir(resource)) {
utils
.findFiles(resource, settings.fileExtensions, settings.excludeFiles)
.forEach(function(file) {
subTasks.push(function(subcb) {
yaspeller.checkFile(file, function(err, data, originalText) {
onResource(err, data, originalText);
subcb();
}, settings);
});
});
async.parallelLimit(subTasks, settings.maxRequests, function() {
cb();
});
} else {
const file = pth.resolve(resource);
if (utils.isExcludedFile(file, settings.excludeFiles)) {
cb();
} else {
yaspeller.checkFile(file, function(err, data, originalText) {
onResource(err, data, originalText);
cb();
}, settings);
}
}
} else {
onResource(true, Error(resource + ': is not exists'));
cb();
}
onResource(true, Error(`${resource}: is not exists`));
callback();
}
});
}
});
return tasks;
},

@@ -109,23 +91,76 @@ /**

forStdin(settings) {
return [function(cb) {
return [function(callback) {
let text = '';
process.stdin.setEncoding('utf8');
process.stdin
.setEncoding('utf8')
.on('readable', () => {
const chunk = process.stdin.read();
if (chunk !== null) {
text += chunk;
}
})
.on('end', function() {
const startTime = Date.now();
yaspeller.checkText(text, (err, data, originalText) => {
onResource(
err,
err ? data : {
resource: 'stdin',
data: data,
time: Date.now() - startTime
},
originalText
);
callback();
}, settings);
});
}];
},
/**
* Prepare tasks for files.
*
* @param {string} resource
* @param {Object} settings
* @param {Function} callback
*/
forFiles(resource, settings, callback) {
if (utils.isDir(resource)) {
const tasks = utils
.findFiles(resource, settings.fileExtensions, settings.excludeFiles)
.map(file => cb => yaspeller.checkFile(file, (err, data, originalText) => {
onResource(err, data, originalText);
cb();
}, settings));
process.stdin.on('readable', function() {
const chunk = process.stdin.read();
if (chunk !== null) {
text += chunk;
}
});
process.stdin.on('end', function() {
const startTime = Date.now();
yaspeller.checkText(text, function(err, data, originalText) {
onResource(err, err ? data : {resource: 'stdin', data: data, time: Date.now() - startTime}, originalText);
cb();
async.parallelLimit(tasks, settings.maxRequests, callback);
} else {
const file = pth.resolve(resource);
if (utils.isExcludedFile(file, settings.excludeFiles)) {
callback();
} else {
yaspeller.checkFile(file, (err, data, originalText) => {
onResource(err, data, originalText);
callback();
}, settings);
});
}];
}
}
},
/**
* Prepare tasks for a url.
*
* @param {string} resource
* @param {Object} settings
* @param {Function} callback
*/
forUrl(resource, settings, callback) {
if (utils.isSitemap(resource)) {
yaspeller.checkSitemap(resource, callback, settings, onResource);
} else {
yaspeller.checkUrl(resource, (err, data, originalText) => {
onResource(err, data, originalText);
callback();
}, settings);
}
}
};

@@ -5,4 +5,4 @@ 'use strict';

const entities = require('entities');
const eyo = require('eyo-kernel');
const fs = require('fs');
const eyo = require('./eyo');
const formatModule = require('./format');

@@ -112,3 +112,3 @@ const ignore = require('./ignore');

function checkYo(text, data) {
eyo.lint(text, true).safe.forEach(function(el) {
eyo(text).forEach(function(el) {
data.push({

@@ -115,0 +115,0 @@ code: 100,

@@ -13,3 +13,3 @@ {

"description": "Search tool typos in the text, files and websites",
"version": "3.2.0",
"version": "3.3.0",
"license": "MIT",

@@ -36,23 +36,24 @@ "homepage": "https://github.com/hcodes/yaspeller",

"dependencies": {
"async": "~2.1.5",
"chalk": "~1.1.3",
"commander": "~2.9.0",
"eyo-kernel": "~1.0.6",
"entities": "~1.1.1",
"isutf8": "~2.0.1",
"escape-html": "1.0.3",
"minimatch": "~3.0.3",
"request": "~2.81.0",
"showdown": "~1.6.4",
"strip-json-comments": "~2.0.1",
"xml2js": "~0.4.17",
"yandex-speller": "~2.0.1"
"async": "^2.5.0",
"chalk": "^2.0.1",
"commander": "^2.11.0",
"entities": "^1.1.1",
"escape-html": "^1.0.3",
"eyo-kernel": "^2.2.0",
"glob": "^7.1.2",
"isutf8": "^2.0.1",
"minimatch": "^3.0.4",
"request": "^2.81.0",
"showdown": "^1.7.1",
"strip-json-comments": "^2.0.1",
"xml2js": "^0.4.17",
"yandex-speller": "^2.0.1"
},
"devDependencies": {
"chai": "~3.5.0",
"eslint": "~3.17.0",
"chai": "~4.1.0",
"eslint": "~4.3.0",
"istanbul": "~0.4.5",
"jscs": "~3.0.7",
"mocha": "~3.2.0",
"sinon": "~1.17.7"
"mocha": "~3.4.2",
"sinon": "~2.4.1"
},

@@ -59,0 +60,0 @@ "engines": {

@@ -118,3 +118,3 @@ yaspeller

#### `--max-requests <value>`
Max count of requests at a time.<br/>
Max count of requests in parallel.<br/>
Default: `2`.

@@ -121,0 +121,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc