Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

textlint-rule-helper

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

textlint-rule-helper - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

CHANGELOG.md

107

lib/textlint-rule-helper.js

@@ -0,1 +1,11 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
// LICENSE : MIT

@@ -7,47 +17,60 @@ "use strict";

*/
var RuleHelper =
/**
* Initialize RuleHelper with RuleContext object.
* @param {RuleContext} ruleContext the ruleContext is context object of the rule.
*/
function RuleHelper(ruleContext) {
this.ruleContext = ruleContext;
};
/**
* Get parents of node.
* The parent nodes are returned in order from the closest parent to the outer ones.
* {@link node} is not contained in the results.
* @param {TxtNode} node the node is start point.
* @returns {TxtNode[]}
*/
RuleHelper.prototype.getParents = function (node) {
var result = [];
var parent = node.parent;
while (parent != null) {
result.push(parent);
parent = parent.parent;
}
return result;
};
var RuleHelper = (function () {
/**
* Initialize RuleHelper with RuleContext object.
* @param {RuleContext} ruleContext the ruleContext is context object of the rule.
*/
/**
* Return true if `node` is wrapped any one of node {@link types}.
* @param {TxtNode} node is target node
* @param {string[]} types are wrapped target node
* @returns {boolean}
*/
RuleHelper.prototype.isChildNode = function (node, types) {
var parents = this.getParents(node);
var parentsTypes = parents.map(function (parent) {
return parent.type;
});
return types.some(function (type) {
return parentsTypes.some(function (parentType) {
return parentType === type;
});
});
};
function RuleHelper(ruleContext) {
_classCallCheck(this, RuleHelper);
this.ruleContext = ruleContext;
}
_createClass(RuleHelper, [{
key: "getParents",
/**
* Get parents of node.
* The parent nodes are returned in order from the closest parent to the outer ones.
* {@link node} is not contained in the results.
* @param {TxtNode} node the node is start point.
* @returns {TxtNode[]}
*/
value: function getParents(node) {
var result = [];
var parent = node.parent;
while (parent != null) {
result.push(parent);
parent = parent.parent;
}
return result;
}
}, {
key: "isChildNode",
/**
* Return true if `node` is wrapped any one of node {@link types}.
* @param {TxtNode} node is target node
* @param {string[]} types are wrapped target node
* @returns {boolean}
*/
value: function isChildNode(node, types) {
var parents = this.getParents(node);
var parentsTypes = parents.map(function (parent) {
return parent.type;
});
return types.some(function (type) {
return parentsTypes.some(function (parentType) {
return parentType === type;
});
});
}
}]);
return RuleHelper;
})();
exports.RuleHelper = RuleHelper;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy90ZXh0bGludC1ydWxlLWhlbHBlci5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7SUFNYSxVQUFVOzs7OztBQUtSLFNBTEYsVUFBVSxDQUtQLFdBQVcsRUFBRTtBQUNyQixNQUFJLENBQUMsV0FBVyxHQUFHLFdBQVcsQ0FBQztDQUNsQzs7Ozs7Ozs7O0FBUFEsVUFBVSxXQWdCbkIsVUFBVSxHQUFBLFVBQUMsSUFBSSxFQUFFO0FBQ2IsTUFBSSxNQUFNLEdBQUcsRUFBRSxDQUFDO0FBQ2hCLE1BQUksTUFBTSxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUM7QUFDekIsU0FBTyxNQUFNLElBQUksSUFBSSxFQUFFO0FBQ25CLFVBQU0sQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLENBQUM7QUFDcEIsVUFBTSxHQUFHLE1BQU0sQ0FBQyxNQUFNLEN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RydWN0b3IocnVsZUNvbnRleHQpIHtcbiAgICAgICAgdGhpcy5ydWxlQ29udGV4dCA9IHJ1bGVDb250ZXh0O1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIEdldCBwYXJlbnRzIG9mIG5vZGUuXG4gICAgICogVGhlIHBhcmVudCBub2RlcyBhcmUgcmV0dXJuZWQgaW4gb3JkZXIgZnJvbSB0aGUgY2xvc2VzdCBwYXJlbnQgdG8gdGhlIG91dGVyIG9uZXMuXG4gICAgICoge0BsaW5rIG5vZGV9IGlzIG5vdCBjb250YWluZWQgaW4gdGhlIHJlc3VsdHMuXG4gICAgICogQHBhcmFtIHtUeHROb2RlfSBub2RlIHRoZSBub2RlIGlzIHN0YXJ0IHBvaW50LlxuICAgICAqIEByZXR1cm5zIHtUeHROb2RlW119XG4gICAgICovXG4gICAgZ2V0UGFyZW50cyhub2RlKSB7XG4gICAgICAgIHZhciByZXN1bHQgPSBbXTtcbiAgICAgICAgdmFyIHBhcmVudCA9IG5vZGUucGFyZW50O1xuICAgICAgICB3aGlsZSAocGFyZW50ICE9IG51bGwpIHtcbiAgICAgICAgICAgIHJlc3VsdC5wdXNoKHBhcmVudCk7XG4gICAgICAgICAgICBwYXJlbnQgPSBwYXJlbnQucGFyZW50O1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogUmV0dXJuIHRydWUgaWYgYG5vZGVgIGlzIHdyYXBwZWQgYW55IG9uZSBvZiBub2RlIHtAbGluayB0eXBlc30uXG4gICAgICogQHBhcmFtIHtUeHROb2RlfSBub2RlIGlzIHRhcmdldCBub2RlXG4gICAgICogQHBhcmFtIHtzdHJpbmdbXX0gdHlwZXMgYXJlIHdyYXBwZWQgdGFyZ2V0IG5vZGVcbiAgICAgKiBAcmV0dXJucyB7Ym9vbGVhbn1cbiAgICAgKi9cbiAgICBpc0NoaWxkTm9kZShub2RlLCB0eXBlcykge1xuICAgICAgICB2YXIgc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0KSB7XG4gICAgICAgIHRoaXMucnVsZUNvbnRleHQgPSBydWxlQ29udGV4dDtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBHZXQgcGFyZW50cyBvZiBub2RlLlxuICAgICAqIFRoZSBwYXJlbnQgbm9kZXMgYXJlIHJldHVybmVkIGluIG9yZGVyIGZyb20gdGhlIGNsb3Nlc3QgcGFyZW50IHRvIHRoZSBvdXRlciBvbmVzLlxuICAgICAqIHtAbGluayBub2RlfSBpcyBub3QgY29udGFpbmVkIGluIHRoZSByZXN1bHRzLlxuICAgICAqIEBwYXJhbSB7VHh0Tm9kZX0gbm9kZSB0aGUgbm9kZSBpcyBzdGFydCBwb2ludC5cbiAgICAgKiBAcmV0dXJucyB7VHh0Tm9kZVtdfVxuICAgICAqL1xuICAgIGdldFBhcmVudHMobm9kZSkge1xuICAgICAgICB2YXIgcmVzdWx0ID0gW107XG4gICAgICAgIHZhciBwYXJlbnQgPSBub2RlLnBhcmVudDtcbiAgICAgICAgd2hpbGUgKHBhcmVudCAhPSBudWxsKSB7XG4gICAgICAgICAgICByZXN1bHQucHVzaChwYXJlbnQpO1xuICAgICAgICAgICAgcGFyZW50ID0gcGFyZW50LnBhcmVudDtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFJldHVybiB0cnVlIGlmIGBub2RlYCBpcyB3cmFwcGVkIGFueSBvbmUgb2Ygbm9kZSB7QGxpbmsgdHlwZXN9LlxuICAgICAqIEBwYXJhbSB7VHh0Tm9kZX0gbm9kZSBpcyB0YXJnZXQgbm9kZVxuICAgICAqIEBwYXJhbSB7c3RyaW5nW119IHR5cGVzIGFyZSB3cmFwcGVkIHRhcmdldCBub2RlXG4gICAgICogQHJldHVybnMge2Jvb2xlYW59XG4gICAgICovXG4gICAgaXNDaGlsZE5vZGUobm9kZSwgdHlwZXMpIHtcbiAgICAgICAgdmFyIHBhcmVudHMgPSB0aGlzLmdldFBhcmVudHMobm9kZSk7XG4gICAgICAgIHZhciBwYXJlbnRzVHlwZXMgPSBwYXJlbnRzLm1hcChmdW5jdGlvbiAocGFyZW50KSB7XG4gICAgICAgICAgICByZXR1cm4gcGFyZW50LnR5cGU7XG4gICAgICAgIH0pO1xuICAgICAgICByZXR1cm4gdHlwZXMuc29tZShmdW5jdGlvbiAodHlwZSkge1xuICAgICAgICAgICAgcmV0dXJuIHBhcmVudHNUeXBlcy5zb21lKGZ1bmN0aW9uIChwYXJlbnRUeXBlKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHBhcmVudFR5cGUgPT09IHR5cGU7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgfVxufSJdfQ==
{
"name": "textlint-rule-helper",
"description": "Helper for textlint rule.",
"version": "1.1.2",
"version": "1.1.3",
"homepage": "https://github.com/azu/textlint-rule-helper/",

@@ -15,4 +15,4 @@ "repository": {

"scripts": {
"build ": "6to5 src --out-dir lib --source-maps-inline",
"watch": "6to5 src --out-dir lib --watch --source-maps-inline",
"build": "babel src --out-dir lib --source-maps inline",
"watch": "babel src --out-dir lib --watch --source-maps inline",
"docs": "jsdoc2md -t template/README.template.md lib/textlint-rule-helper.js > README.md",

@@ -30,14 +30,12 @@ "test": "npm run build && mocha test/*.js"

"devDependencies": {
"6to5": "^2.7.4",
"espower-6to5": "^1.0.1",
"espower-loader": "^0.10.0",
"intelli-espower-loader": "^0.5.0",
"jsdoc-to-markdown": "^0.5.9",
"markdown-to-ast": "^2.2.0",
"babel": "^5.2.17",
"espower-babel": "^3.0.0",
"jsdoc-to-markdown": "^1.1.1",
"markdown-to-ast": "^3.0.5",
"mocha": "^2.1.0",
"power-assert": "^0.10.0",
"power-assert": "^0.11.0",
"source-map-support": "^0.2.8",
"textlint": "^1.4.3",
"textlint": "^3.1.2",
"txt-ast-traverse": "^1.2.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