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

mkast

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mkast - npm Package Compare versions

Comparing version 1.1.8 to 1.1.9

6

lib/deserialize.js

@@ -47,2 +47,4 @@ var through = require('through3')

var completed = isEof && this.open === 0;
// handle documet nodes

@@ -71,7 +73,7 @@ if(isDocument) {

// attach to current doc
}else if(this.doc && !isEof) {
}else if(this.doc && !completed) {
this.doc.appendChild(attach(chunk));
// got EOF with a valid root doc, flush it
}else if(this.doc && isEof && this.open === 0) {
}else if(this.doc && completed) {
this.push(this.doc);

@@ -78,0 +80,0 @@ this.emit(Node.EOF, this.doc);

var through = require('through3')
, Node = require('./node')
, detach = require('./detach');

@@ -14,13 +15,21 @@

* @member AstWalk
* @param {Array} ast input AST document.
* @param {Array} chunk input AST node.
* @param {String} encoding character encoding.
* @param {Function} callback function.
*/
function transform(ast, encoding, cb) {
function transform(chunk, encoding, cb) {
// TODO: error on bad data
if(!chunk) {
return cb(new Error('ast node expected'));
}
var nodes = [];
if(ast && ast.type === 'document' && ast._firstChild) {
//if(ast && ast._firstChild) {
// exapand child nodes of documents, this creates a pseudo stream
// from the input document
if(chunk._type === Node.DOCUMENT && chunk._firstChild) {
// push direct descendants
var next = ast._firstChild;
var next = chunk._firstChild;
while(next) {

@@ -31,5 +40,5 @@ nodes.push(next);

// trim document ast
detach(ast);
this.push(ast);
// trim document chunk
detach(chunk);
this.push(chunk);

@@ -42,6 +51,8 @@ for(var i = 0;i < nodes.length;i++) {

if(this.EOF !== false) {
this.push({_type: 'eof'});
this.push(Node.createNode(Node.EOF, {_file: chunk._file}));
}
// pass through other nodes
}else{
this.push(ast);
this.push(chunk);
}

@@ -48,0 +59,0 @@ cb();

{
"name": "mkast",
"version": "1.1.8",
"version": "1.1.9",
"description": "Commonmark AST transformer",

@@ -5,0 +5,0 @@ "main": "index.js",

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