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

retext

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

retext - npm Package Compare versions

Comparing version 0.1.0-rc.2 to 0.1.0-rc.3

5

component.json

@@ -5,3 +5,3 @@ {

"description": "Extensible system for analysing and manipulating natural language",
"version": "0.1.0-rc.2",
"version": "0.1.0-rc.3",
"keywords": [

@@ -17,3 +17,4 @@ "natural",

"dependencies": {
"wooorm/parse-english": "^0.0.23"
"parse-latin": "^0.1.0-rc.6",
"textom": "^0.1.0-rc.3"
},

@@ -20,0 +21,0 @@ "scripts" : [

0.1.0-rc.3 / 2014-07-12
==================
* Update dependencies in component.json
* Removed functionality to pass strings to the Retext constructor
* Added an example to the Retext docs on how to use custom parsers
* Added a missing semicolon
* Retext now exposes an `applyPlugins` method (fixes #8)
* Added unit tests for Retext#applyPlugins
0.1.0-rc.2 / 2014-07-11

@@ -3,0 +13,0 @@ ==================

52

index.js
'use strict';
var TextOMConstructor = require('textom');
var TextOMConstructor = require('textom'),
ParseLatin = require('parse-latin');

@@ -44,4 +45,3 @@ function fromAST(TextOM, ast) {

*
* @param {(Object|String)?} parser - the parser, or its name, to use.
* Defaults to "parse-latin".
* @param {Function?} parser - the parser to use. Defaults to parse-latin.
* @api public

@@ -54,17 +54,5 @@ * @constructor

if (!parser) {
parser = 'parse-latin';
parser = new ParseLatin();
}
if (typeof parser === 'string') {
/* istanbul ignore else: TODO / TOSPEC */
/* Load the parser for vendors without dynamic-require's */
if (parser === 'parse-latin') {
parser = require('parse-latin');
} else {
parser = require(parser);
}
parser = parser();
}
self.parser = parser;

@@ -117,2 +105,19 @@ self.TextOM = parser.TextOM = new TextOMConstructor();

*
* @param {String?} source - The source to convert.
* @return {Node} - A RootNode containing the tokenised source.
* @api public
*/
Retext.prototype.parse = function (source) {
var self = this,
rootNode = fromAST(self.TextOM, self.parser.tokenizeRoot(source));
self.applyPlugins(rootNode);
return rootNode;
};
/**
* `Retext#applyPlugins` applies the plugins bound to the retext instance to a
* given tree.
*
* Note that, during the parsing stage, when the `use` plugin is called

@@ -122,23 +127,18 @@ * by a plugin, the nested plugin is immediately called, before continuing

*
* @param {(String|Node)?} source - The source to convert.
* @return {Node} - A RootNode containing the tokenised source.
* @param {Node} tree - The tree to apply plugins to.
* @api public
*/
Retext.prototype.parse = function (source) {
Retext.prototype.applyPlugins = function (tree) {
var self = this,
parser = self.parser,
plugins = self.plugins.concat(),
iterator = -1,
use = self.use,
rootNode = fromAST(self.TextOM, parser.tokenizeRoot(source));
use = self.use;
self.use = useImmediately(rootNode, use);
self.use = useImmediately(tree, use);
while (plugins[++iterator]) {
plugins[iterator](rootNode, this);
plugins[iterator](tree, this);
}
self.use = use;
return rootNode;
};

@@ -145,0 +145,0 @@

{
"name": "retext",
"version": "0.1.0-rc.2",
"version": "0.1.0-rc.3",
"description": "Extensible system for analysing and manipulating natural language",

@@ -5,0 +5,0 @@ "keywords": [

@@ -42,3 +42,3 @@ # ![Retext logo](http://i58.tinypic.com/5xpx5z.png)

'who hears no evil; and Iwazaru (:speak_no_evil:), ' +
'covering his mouth, who speaks no evil.'
'covering his mouth, who speaks no evil.';

@@ -66,5 +66,11 @@ var text = new Retext()

### Retext(parser)
```js
var Retext = require('retext'),
ParseEnglish = require('parse-english');
Return a new `Retext` instance with the given parser (defaults to `"parse-english"`).
var retext = new Retext(new ParseEnglish()).parse(/* ...some english... */);
```
Return a new `Retext` instance with the given parser (defaults to parse-latin).
### Retext.prototype.use(plugin)

@@ -71,0 +77,0 @@

@@ -240,1 +240,8 @@ 'use strict';

});
describe('Retext#applyPlugins', function () {
it('should be of type `function`', function () {
assert(typeof Retext.prototype.applyPlugins === 'function');
assert(typeof (new Retext()).applyPlugins === 'function');
});
});
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