browserify fully implemented

This commit is contained in:
Phil Kunz 2015-10-24 20:55:14 +02:00
parent bed96b42ac
commit c0f5b1f460
9 changed files with 198 additions and 120 deletions

101
.idea/workspace.xml generated
View File

@ -2,12 +2,14 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="b850c661-13d4-478c-951c-1a06c2a6f1db" name="Default" comment=""> <list default="true" id="b850c661-13d4-478c-951c-1a06c2a6f1db" name="Default" comment="">
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.gitignore" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.travis.yml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/ts/modulebrowserify.ts" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/index.js" afterPath="$PROJECT_DIR$/index.js" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/package.json" afterPath="$PROJECT_DIR$/package.json" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/package.json" afterPath="$PROJECT_DIR$/package.json" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/ts/index.ts" afterPath="$PROJECT_DIR$/ts/index.ts" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/ts/index.ts" afterPath="$PROJECT_DIR$/ts/index.ts" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/ts/modulebrowserify.ts" afterPath="$PROJECT_DIR$/ts/modulebrowserify.ts" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/ts/tsd.json" afterPath="$PROJECT_DIR$/ts/tsd.json" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/ts/typings/node/node.d.ts" afterPath="$PROJECT_DIR$/ts/typings/node/node.d.ts" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/ts/typings/tsd.d.ts" afterPath="$PROJECT_DIR$/ts/typings/tsd.d.ts" />
</list> </list>
<ignored path="gulp-browser.iws" /> <ignored path="gulp-browser.iws" />
<ignored path=".idea/workspace.xml" /> <ignored path=".idea/workspace.xml" />
@ -31,8 +33,8 @@
<file leaf-file-name="index.ts" pinned="false" current-in-tab="false"> <file leaf-file-name="index.ts" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/ts/index.ts"> <entry file="file://$PROJECT_DIR$/ts/index.ts">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-5.3333335"> <state vertical-scroll-proportion="0.0">
<caret line="8" column="19" selection-start-line="8" selection-start-column="19" selection-end-line="8" selection-end-column="19" /> <caret line="12" column="54" selection-start-line="12" selection-start-column="54" selection-end-line="12" selection-end-column="54" />
<folding> <folding>
<element signature="n#!!doc" expanded="true" /> <element signature="n#!!doc" expanded="true" />
</folding> </folding>
@ -43,8 +45,18 @@
<file leaf-file-name="modulebrowserify.ts" pinned="false" current-in-tab="true"> <file leaf-file-name="modulebrowserify.ts" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/ts/modulebrowserify.ts"> <entry file="file://$PROJECT_DIR$/ts/modulebrowserify.ts">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.114893615"> <state vertical-scroll-proportion="0.4">
<caret line="3" column="87" selection-start-line="3" selection-start-column="87" selection-end-line="3" selection-end-column="87" /> <caret line="11" column="59" selection-start-line="11" selection-start-column="59" selection-end-line="11" selection-end-column="59" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="index.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/index.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="28" column="29" selection-start-line="28" selection-start-column="29" selection-end-line="28" selection-end-column="29" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -72,8 +84,8 @@
<file leaf-file-name="package.json" pinned="false" current-in-tab="false"> <file leaf-file-name="package.json" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/package.json"> <entry file="file://$PROJECT_DIR$/package.json">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-0.5"> <state vertical-scroll-proportion="-20.0">
<caret line="6" column="38" selection-start-line="3" selection-start-column="18" selection-end-line="3" selection-end-column="63" /> <caret line="32" column="4" selection-start-line="32" selection-start-column="4" selection-end-line="32" selection-end-column="4" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -107,11 +119,11 @@
<component name="IdeDocumentHistory"> <component name="IdeDocumentHistory">
<option name="CHANGED_PATHS"> <option name="CHANGED_PATHS">
<list> <list>
<option value="$PROJECT_DIR$/package.json" />
<option value="$PROJECT_DIR$/README.md" /> <option value="$PROJECT_DIR$/README.md" />
<option value="$PROJECT_DIR$/.gitignore" /> <option value="$PROJECT_DIR$/.gitignore" />
<option value="$PROJECT_DIR$/.travis.yml" /> <option value="$PROJECT_DIR$/.travis.yml" />
<option value="$PROJECT_DIR$/ts/browserify.ts" /> <option value="$PROJECT_DIR$/ts/browserify.ts" />
<option value="$PROJECT_DIR$/package.json" />
<option value="$PROJECT_DIR$/ts/index.ts" /> <option value="$PROJECT_DIR$/ts/index.ts" />
<option value="$PROJECT_DIR$/ts/modulebrowserify.ts" /> <option value="$PROJECT_DIR$/ts/modulebrowserify.ts" />
</list> </list>
@ -184,24 +196,6 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT> </PATH_ELEMENT>
</PATH> </PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="gulp-browser" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="gulp-browser" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="ts" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="compile" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane> </subPane>
</pane> </pane>
<pane id="Scope" /> <pane id="Scope" />
@ -209,7 +203,7 @@
</panes> </panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="last_opened_file_path" value="$PROJECT_DIR$" /> <property name="last_opened_file_path" value="$PROJECT_DIR$/../gulp-makejson" />
<property name="WebServerToolWindowFactoryState" value="false" /> <property name="WebServerToolWindowFactoryState" value="false" />
<property name="js-jscs-nodeInterpreter" value="/usr/local/bin/node" /> <property name="js-jscs-nodeInterpreter" value="/usr/local/bin/node" />
<property name="HbShouldOpenHtmlAsHb" value="" /> <property name="HbShouldOpenHtmlAsHb" value="" />
@ -287,13 +281,14 @@
<frame x="0" y="23" width="1440" height="873" extended-state="0" /> <frame x="0" y="23" width="1440" height="873" extended-state="0" />
<editor active="true" /> <editor active="true" />
<layout> <layout>
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.24947146" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.24947146" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" /> <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" /> <window_info id="TypeScript Compiler" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.33034572" sideWeight="0.5024665" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="8" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32950193" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Terminal" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.33034572" sideWeight="0.49753347" order="10" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" /> <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" /> <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
@ -330,14 +325,6 @@
<state /> <state />
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/package.json">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-0.5">
<caret line="6" column="38" selection-start-line="3" selection-start-column="18" selection-end-line="3" selection-end-column="63" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/.gitignore"> <entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-0.8181818"> <state vertical-scroll-proportion="-0.8181818">
@ -362,10 +349,34 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/index.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="28" column="29" selection-start-line="28" selection-start-column="29" selection-end-line="28" selection-end-column="29" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/ts/tsd.json">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/package.json">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-20.0">
<caret line="32" column="4" selection-start-line="32" selection-start-column="4" selection-end-line="32" selection-end-column="4" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/ts/index.ts"> <entry file="file://$PROJECT_DIR$/ts/index.ts">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-5.3333335"> <state vertical-scroll-proportion="0.0">
<caret line="8" column="19" selection-start-line="8" selection-start-column="19" selection-end-line="8" selection-end-column="19" /> <caret line="12" column="54" selection-start-line="12" selection-start-column="54" selection-end-line="12" selection-end-column="54" />
<folding> <folding>
<element signature="n#!!doc" expanded="true" /> <element signature="n#!!doc" expanded="true" />
</folding> </folding>
@ -374,8 +385,8 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/ts/modulebrowserify.ts"> <entry file="file://$PROJECT_DIR$/ts/modulebrowserify.ts">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.114893615"> <state vertical-scroll-proportion="0.4">
<caret line="3" column="87" selection-start-line="3" selection-start-column="87" selection-end-line="3" selection-end-column="87" /> <caret line="11" column="59" selection-start-line="11" selection-start-column="59" selection-end-line="11" selection-end-column="59" />
<folding /> <folding />
</state> </state>
</provider> </provider>

View File

@ -1,11 +1,15 @@
/// <reference path="./index.ts" />
var GulpBrowserBrowserify; var GulpBrowserBrowserify;
(function (GulpBrowserBrowserify) { (function (GulpBrowserBrowserify) {
function init() { function init() {
return function () { return function () {
//this is the trough object that gets returned by gulpBrowser.browserify(); //this is the trough object that gets returned by gulpBrowser.browserify();
return through.obj(function (file, enc, cb) { return through.obj(function (file, enc, cb) {
var content = file.content; var content = String(file.contents);
var basedir = file.base; var basedir = file.base;
var bundleCallback = function (err, bundledBuffer) {
};
browserify(content).bundle(bundleCallback);
//run callback function to signal end of plugin process. //run callback function to signal end of plugin process.
return cb(null, file); return cb(null, file);
}); });
@ -18,6 +22,7 @@ var GulpBrowserBrowserify;
var through = require("through2"); var through = require("through2");
var path = require("path"); var path = require("path");
var browserify = require("browserify"); var browserify = require("browserify");
var pr = require("pushrocks");
//create the return object //create the return object
var gulpBrowser = {}; var gulpBrowser = {};
gulpBrowser.browserify = GulpBrowserBrowserify.init(); gulpBrowser.browserify = GulpBrowserBrowserify.init();

View File

@ -25,7 +25,10 @@
}, },
"homepage": "https://github.com/pushrocks/gulp-browser", "homepage": "https://github.com/pushrocks/gulp-browser",
"dependencies": { "dependencies": {
"browserify": "^11.2.0" "browserify": "^11.2.0",
"gutil": "^1.6.4",
"pushrocks": "^1.0.18",
"through2": "^2.0.0"
}, },
"devDependencies": { "devDependencies": {
"gulp": "3.9.0", "gulp": "3.9.0",

View File

@ -2,8 +2,10 @@
/// <reference path="./modulebrowserify.ts" /> /// <reference path="./modulebrowserify.ts" />
var through = require("through2"); var through = require("through2");
var gutil = require("gulp-util");
var path = require("path"); var path = require("path");
var browserify = require("browserify"); var browserify = require("browserify");
var pr = require("pushrocks");
//create the return object //create the return object
var gulpBrowser:any = {}; var gulpBrowser:any = {};

View File

@ -1,16 +1,15 @@
/// <reference path="./index.ts" />
module GulpBrowserBrowserify { module GulpBrowserBrowserify {
export function init() { export function init() {
return function() { return function() {
//this is the trough object that gets returned by gulpBrowser.browserify(); return through.obj((file, enc, cb) => { //this is the trough object that gets returned by gulpBrowser.browserify();
return through.obj((file, enc, cb) => { var content = String(file.contents); // get the content of the file
var content = file.content; var bundleCallback = (err,bundledBuffer) => { //gets called by browserify, arrow function (TS) preserves this
var basedir = file.base; file.contents = bundledBuffer;
this.push(file);
cb();
};
browserify(content).bundle(bundleCallback);
//run callback function to signal end of plugin process.
return cb(null, file);
}); });
}; };
} }

View File

@ -6,7 +6,10 @@
"bundle": "typings/tsd.d.ts", "bundle": "typings/tsd.d.ts",
"installed": { "installed": {
"node/node.d.ts": { "node/node.d.ts": {
"commit": "efa0c1196d7280640e624ac1e7fa604502e7bd63" "commit": "3191f6e0088eee07c4d8fd24e4d27a40a60d9eb9"
},
"browserify/browserify.d.ts": {
"commit": "3191f6e0088eee07c4d8fd24e4d27a40a60d9eb9"
} }
} }
} }

41
ts/typings/browserify/browserify.d.ts vendored Normal file
View File

@ -0,0 +1,41 @@
// Type definitions for Browserify
// Project: http://browserify.org/
// Definitions by: Andrew Gaspar <https://github.com/AndrewGaspar/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
interface BrowserifyObject extends NodeJS.EventEmitter {
add(file:string, opts?:any): BrowserifyObject;
require(file:string, opts?:{
expose: string;
}): BrowserifyObject;
bundle(opts?:{
insertGlobals?: boolean;
detectGlobals?: boolean;
debug?: boolean;
standalone?: string;
insertGlobalVars?: any;
}, cb?:(err:any, src:any) => void): NodeJS.ReadableStream;
external(file:string, opts?:any): BrowserifyObject;
ignore(file:string, opts?:any): BrowserifyObject;
transform(tr:string, opts?:any): BrowserifyObject;
transform(tr:Function, opts?:any): BrowserifyObject;
plugin(plugin:string, opts?:any): BrowserifyObject;
plugin(plugin:Function, opts?:any): BrowserifyObject;
}
interface Browserify {
(): BrowserifyObject;
(files:string[]): BrowserifyObject;
(opts:{
entries?: string[];
noParse?: string[];
}): BrowserifyObject;
}
declare module "browserify" {
var browserify: Browserify;
export = browserify;
}

View File

@ -9,6 +9,11 @@
* * * *
************************************************/ ************************************************/
interface Error {
stack?: string;
}
// compat for TypeScript 1.5.3 // compat for TypeScript 1.5.3
// if you use with --target es3 or --target es5 and use below definitions, // if you use with --target es3 or --target es5 and use below definitions,
// use the lib.es6.d.ts that is bundled with TypeScript 1.5.3. // use the lib.es6.d.ts that is bundled with TypeScript 1.5.3.
@ -114,7 +119,7 @@ declare var Buffer: {
* *
* @param obj object to test. * @param obj object to test.
*/ */
isBuffer(obj: any): boolean; isBuffer(obj: any): obj is Buffer;
/** /**
* Returns true if {encoding} is a valid encoding argument. * Returns true if {encoding} is a valid encoding argument.
* Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
@ -188,8 +193,7 @@ declare module NodeJS {
export interface WritableStream extends EventEmitter { export interface WritableStream extends EventEmitter {
writable: boolean; writable: boolean;
write(buffer: Buffer, cb?: Function): boolean; write(buffer: Buffer|string, cb?: Function): boolean;
write(str: string, cb?: Function): boolean;
write(str: string, encoding?: string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean;
end(): void; end(): void;
end(buffer: Buffer, cb?: Function): void; end(buffer: Buffer, cb?: Function): void;
@ -373,21 +377,21 @@ interface NodeBuffer {
readFloatBE(offset: number, noAssert?: boolean): number; readFloatBE(offset: number, noAssert?: boolean): number;
readDoubleLE(offset: number, noAssert?: boolean): number; readDoubleLE(offset: number, noAssert?: boolean): number;
readDoubleBE(offset: number, noAssert?: boolean): number; readDoubleBE(offset: number, noAssert?: boolean): number;
writeUInt8(value: number, offset: number, noAssert?: boolean): void; writeUInt8(value: number, offset: number, noAssert?: boolean): number;
writeUInt16LE(value: number, offset: number, noAssert?: boolean): void; writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
writeUInt16BE(value: number, offset: number, noAssert?: boolean): void; writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
writeUInt32LE(value: number, offset: number, noAssert?: boolean): void; writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
writeUInt32BE(value: number, offset: number, noAssert?: boolean): void; writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
writeInt8(value: number, offset: number, noAssert?: boolean): void; writeInt8(value: number, offset: number, noAssert?: boolean): number;
writeInt16LE(value: number, offset: number, noAssert?: boolean): void; writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
writeInt16BE(value: number, offset: number, noAssert?: boolean): void; writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
writeInt32LE(value: number, offset: number, noAssert?: boolean): void; writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
writeInt32BE(value: number, offset: number, noAssert?: boolean): void; writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
writeFloatLE(value: number, offset: number, noAssert?: boolean): void; writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
writeFloatBE(value: number, offset: number, noAssert?: boolean): void; writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
writeDoubleLE(value: number, offset: number, noAssert?: boolean): void; writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
writeDoubleBE(value: number, offset: number, noAssert?: boolean): void; writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
fill(value: any, offset?: number, end?: number): void; fill(value: any, offset?: number, end?: number): Buffer;
} }
/************************************************ /************************************************
@ -856,7 +860,7 @@ declare module "child_process" {
env?: any; env?: any;
encoding?: string; encoding?: string;
timeout?: number; timeout?: number;
maxBuffer?: string; maxBuffer?: number;
killSignal?: string; killSignal?: string;
}, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess;
export function fork(modulePath: string, args?: string[], options?: { export function fork(modulePath: string, args?: string[], options?: {
@ -864,6 +868,26 @@ declare module "child_process" {
env?: any; env?: any;
encoding?: string; encoding?: string;
}): ChildProcess; }): ChildProcess;
export function spawnSync(command: string, args?: string[], options?: {
cwd?: string;
input?: string | Buffer;
stdio?: any;
env?: any;
uid?: number;
gid?: number;
timeout?: number;
maxBuffer?: number;
killSignal?: string;
encoding?: string;
}): {
pid: number;
output: string[];
stdout: string | Buffer;
stderr: string | Buffer;
status: number;
signal: string;
error: Error;
};
export function execSync(command: string, options?: { export function execSync(command: string, options?: {
cwd?: string; cwd?: string;
input?: string|Buffer; input?: string|Buffer;
@ -875,7 +899,7 @@ declare module "child_process" {
maxBuffer?: number; maxBuffer?: number;
killSignal?: string; killSignal?: string;
encoding?: string; encoding?: string;
}): ChildProcess; }): string | Buffer;
export function execFileSync(command: string, args?: string[], options?: { export function execFileSync(command: string, args?: string[], options?: {
cwd?: string; cwd?: string;
input?: string|Buffer; input?: string|Buffer;
@ -887,7 +911,7 @@ declare module "child_process" {
maxBuffer?: number; maxBuffer?: number;
killSignal?: string; killSignal?: string;
encoding?: string; encoding?: string;
}): ChildProcess; }): string | Buffer;
} }
declare module "url" { declare module "url" {
@ -1062,6 +1086,7 @@ declare module "fs" {
atime: Date; atime: Date;
mtime: Date; mtime: Date;
ctime: Date; ctime: Date;
birthtime: Date;
} }
interface FSWatcher extends events.EventEmitter { interface FSWatcher extends events.EventEmitter {
@ -1214,6 +1239,9 @@ declare module "fs" {
export function fsyncSync(fd: number): void; export function fsyncSync(fd: number): void;
export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
export function write(fd: number, buffer: Buffer, offset: number, length: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; export function write(fd: number, buffer: Buffer, offset: number, length: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
export function write(fd: number, data: any, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
export function write(fd: number, data: any, offset: number, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
export function write(fd: number, data: any, offset: number, encoding: string, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number;
export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void; export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void;
export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number;
@ -1302,21 +1330,15 @@ declare module "fs" {
export function createReadStream(path: string, options?: { export function createReadStream(path: string, options?: {
flags?: string; flags?: string;
encoding?: string; encoding?: string;
fd?: string; fd?: number;
mode?: number; mode?: number;
bufferSize?: number; autoClose?: boolean;
}): ReadStream;
export function createReadStream(path: string, options?: {
flags?: string;
encoding?: string;
fd?: string;
mode?: string;
bufferSize?: number;
}): ReadStream; }): ReadStream;
export function createWriteStream(path: string, options?: { export function createWriteStream(path: string, options?: {
flags?: string; flags?: string;
encoding?: string; encoding?: string;
string?: string; fd?: number;
mode?: number;
}): WriteStream; }): WriteStream;
} }
@ -1622,12 +1644,12 @@ declare module "crypto" {
setAutoPadding(auto_padding: boolean): void; setAutoPadding(auto_padding: boolean): void;
} }
export function createSign(algorithm: string): Signer; export function createSign(algorithm: string): Signer;
interface Signer { interface Signer extends NodeJS.WritableStream {
update(data: any): void; update(data: any): void;
sign(private_key: string, output_format: string): string; sign(private_key: string, output_format: string): string;
} }
export function createVerify(algorith: string): Verify; export function createVerify(algorith: string): Verify;
interface Verify { interface Verify extends NodeJS.WritableStream {
update(data: any): void; update(data: any): void;
verify(object: string, signature: string, signature_format?: string): boolean; verify(object: string, signature: string, signature_format?: string): boolean;
} }
@ -1671,14 +1693,13 @@ declare module "stream" {
readable: boolean; readable: boolean;
constructor(opts?: ReadableOptions); constructor(opts?: ReadableOptions);
_read(size: number): void; _read(size: number): void;
read(size?: number): string|Buffer; read(size?: number): any;
setEncoding(encoding: string): void; setEncoding(encoding: string): void;
pause(): void; pause(): void;
resume(): void; resume(): void;
pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T; pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
unpipe<T extends NodeJS.WritableStream>(destination?: T): void; unpipe<T extends NodeJS.WritableStream>(destination?: T): void;
unshift(chunk: string): void; unshift(chunk: any): void;
unshift(chunk: Buffer): void;
wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
push(chunk: any, encoding?: string): boolean; push(chunk: any, encoding?: string): boolean;
} }
@ -1686,20 +1707,18 @@ declare module "stream" {
export interface WritableOptions { export interface WritableOptions {
highWaterMark?: number; highWaterMark?: number;
decodeStrings?: boolean; decodeStrings?: boolean;
objectMode?: boolean;
} }
export class Writable extends events.EventEmitter implements NodeJS.WritableStream { export class Writable extends events.EventEmitter implements NodeJS.WritableStream {
writable: boolean; writable: boolean;
constructor(opts?: WritableOptions); constructor(opts?: WritableOptions);
_write(data: Buffer, encoding: string, callback: Function): void; _write(chunk: any, encoding: string, callback: Function): void;
_write(data: string, encoding: string, callback: Function): void; write(chunk: any, cb?: Function): boolean;
write(buffer: Buffer, cb?: Function): boolean; write(chunk: any, encoding?: string, cb?: Function): boolean;
write(str: string, cb?: Function): boolean;
write(str: string, encoding?: string, cb?: Function): boolean;
end(): void; end(): void;
end(buffer: Buffer, cb?: Function): void; end(chunk: any, cb?: Function): void;
end(str: string, cb?: Function): void; end(chunk: any, encoding?: string, cb?: Function): void;
end(str: string, encoding?: string, cb?: Function): void;
} }
export interface DuplexOptions extends ReadableOptions, WritableOptions { export interface DuplexOptions extends ReadableOptions, WritableOptions {
@ -1710,15 +1729,12 @@ declare module "stream" {
export class Duplex extends Readable implements NodeJS.ReadWriteStream { export class Duplex extends Readable implements NodeJS.ReadWriteStream {
writable: boolean; writable: boolean;
constructor(opts?: DuplexOptions); constructor(opts?: DuplexOptions);
_write(data: Buffer, encoding: string, callback: Function): void; _write(chunk: any, encoding: string, callback: Function): void;
_write(data: string, encoding: string, callback: Function): void; write(chunk: any, cb?: Function): boolean;
write(buffer: Buffer, cb?: Function): boolean; write(chunk: any, encoding?: string, cb?: Function): boolean;
write(str: string, cb?: Function): boolean;
write(str: string, encoding?: string, cb?: Function): boolean;
end(): void; end(): void;
end(buffer: Buffer, cb?: Function): void; end(chunk: any, cb?: Function): void;
end(str: string, cb?: Function): void; end(chunk: any, encoding?: string, cb?: Function): void;
end(str: string, encoding?: string, cb?: Function): void;
} }
export interface TransformOptions extends ReadableOptions, WritableOptions {} export interface TransformOptions extends ReadableOptions, WritableOptions {}
@ -1728,8 +1744,7 @@ declare module "stream" {
readable: boolean; readable: boolean;
writable: boolean; writable: boolean;
constructor(opts?: TransformOptions); constructor(opts?: TransformOptions);
_transform(chunk: Buffer, encoding: string, callback: Function): void; _transform(chunk: any, encoding: string, callback: Function): void;
_transform(chunk: string, encoding: string, callback: Function): void;
_flush(callback: Function): void; _flush(callback: Function): void;
read(size?: number): any; read(size?: number): any;
setEncoding(encoding: string): void; setEncoding(encoding: string): void;
@ -1737,17 +1752,14 @@ declare module "stream" {
resume(): void; resume(): void;
pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T; pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
unpipe<T extends NodeJS.WritableStream>(destination?: T): void; unpipe<T extends NodeJS.WritableStream>(destination?: T): void;
unshift(chunk: string): void; unshift(chunk: any): void;
unshift(chunk: Buffer): void;
wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
push(chunk: any, encoding?: string): boolean; push(chunk: any, encoding?: string): boolean;
write(buffer: Buffer, cb?: Function): boolean; write(chunk: any, cb?: Function): boolean;
write(str: string, cb?: Function): boolean; write(chunk: any, encoding?: string, cb?: Function): boolean;
write(str: string, encoding?: string, cb?: Function): boolean;
end(): void; end(): void;
end(buffer: Buffer, cb?: Function): void; end(chunk: any, cb?: Function): void;
end(str: string, cb?: Function): void; end(chunk: any, encoding?: string, cb?: Function): void;
end(str: string, encoding?: string, cb?: Function): void;
} }
export class PassThrough extends Transform {} export class PassThrough extends Transform {}
@ -1774,6 +1786,7 @@ declare module "util" {
export function isDate(object: any): boolean; export function isDate(object: any): boolean;
export function isError(object: any): boolean; export function isError(object: any): boolean;
export function inherits(constructor: any, superConstructor: any): void; export function inherits(constructor: any, superConstructor: any): void;
export function debuglog(key:string): (msg:string,...param: any[])=>void;
} }
declare module "assert" { declare module "assert" {

1
ts/typings/tsd.d.ts vendored
View File

@ -1 +1,2 @@
/// <reference path="node/node.d.ts" /> /// <reference path="node/node.d.ts" />
/// <reference path="browserify/browserify.d.ts" />