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

gulp-typedoc-extractor

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

gulp-typedoc-extractor - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

86

index.js
'use strict';
var gutil = require('gulp-util');
var path = require('path');
var nconf = require('nconf');
var File = require('vinyl');
var Transform = require('readable-stream/transform');
var rs = require('replacestream');
var istextorbinary = require('istextorbinary');

@@ -14,61 +15,30 @@ module.exports = function(moduleName) {

}
else if ( file.isStream() ) {
this.emit('error', new gutil.PluginError('gulp-typedoc-extractor', 'Streaming not supported.'));
return callback();
}
function doExtract() {
if (file.isStream()) {
file.contents = file.contents.pipe(rs(search, replacement));
return callback(null, file);
}
try {
var contents = file.contents.toString("utf-8");
var obj = JSON.parse(contents);
console.log('here...');
var outObj = obj.children[0].children[0];
console.log(JSON.stringify(outObj));
file.contents = new Buffer(JSON.stringify(outObj));
return callback(null, file);
if (file.isBuffer()) {
if (search instanceof RegExp) {
file.contents = new Buffer(String(file.contents).replace(search, replacement));
}
else {
var chunks = String(file.contents).split(search);
console.log('here...');
return callback(null, file);
var result;
if (typeof replacement === 'function') {
// Start with the first chunk already in the result
// Replacements will be added thereafter
// This is done to avoid checking the value of i in the loop
result = [ chunks[0] ];
// The replacement function should be called once for each match
for (var i = 1; i < chunks.length; i++) {
// Add the replacement value
result.push(replacement(search));
// Add the next chunk
result.push(chunks[i]);
}
result = result.join('');
}
else {
result = chunks.join(replacement);
}
file.contents = new Buffer(result);
}
return callback(null, file);
}
callback(null, file);
var outFile = File.clone(file);
console.log('here...');
outFile.contents = new Buffer(JSON.stringify(outObj));
this.push(outFile);
return callback(null, outFile);
} catch (e) {
this.emit('error', new gutil.PluginError('gulp-typedoc-extractor', 'Error:'));
callback(e);
}
istextorbinary.isText(file.path, file.contents, function(err, result) {
if (err) {
return callback(err, file);
}
if (!result) {
callback(null, file);
} else {
doExtract();
}
});
return;
}
});
}
});
};
{
"name": "gulp-typedoc-extractor",
"version": "0.0.2",
"version": "0.0.3",
"description": "A post processor to extract a module from gulp-typedoc json output.",
"dependencies": {
"gulp-util": "~3.0.1",
"istextorbinary": "1.0.2",
"nconf": "~0.6.9",
"readable-stream": "^2.0.1",
"replacestream": "^4.0.0",
"nconf": "~0.6.9",
"gulp-util": "~3.0.1",
"through2": "~0.6.1"

@@ -12,0 +12,0 @@ },

@@ -35,4 +35,4 @@ # gulp-typedoc-extractor [![NPM version][npm-image]][npm-url] [![Build status][travis-image]][travis-url]

The module to extract from the json generated by gulp-typedoc.
s
[travis-url]: http://travis-ci.org/lazd/gulp-replace

@@ -39,0 +39,0 @@ [travis-image]: https://secure.travis-ci.org/lazd/gulp-replace.svg?branch=master

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