Skip to content

Commit adf4495

Browse files
committed
Modulify stream
1 parent a7a6bd9 commit adf4495

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ export function compile (str, opt) {
1212
return GLSL(opt).compile(str);
1313
};
1414

15-
export * from './stream.cjs';
15+
export * from './stream.js';
1616

1717
export default GLSL

stream.cjs renamed to stream.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
'use strict'
21
/**
32
* Convert stream of AST nodes to strings.
43
*
54
* @module
65
*/
76

8-
var tokenize = require('glsl-tokenizer/string');
9-
var parse = require('./lib/parse.cjs');
10-
var GLSL = require('./lib/index.cjs');
11-
var Transform = require('stream').Transform;
12-
var inherits = require('inherits');
7+
import tokenize from 'glsl-tokenizer/string.js'
8+
import parse from './lib/parse.cjs'
9+
import GLSL from './lib/index.cjs'
10+
import {Transform} from 'stream'
11+
import inherits from 'inherits'
1312

14-
function GlslJsStream (options) {
15-
if (!(this instanceof GlslJsStream)) return new GlslJsStream(options);
13+
function GlslTranspilerStream (options) {
14+
if (!(this instanceof GlslTranspilerStream)) return new GlslTranspilerStream(options);
1615

1716
Transform.call(this, {
1817
objectMode: true
@@ -32,13 +31,13 @@ function GlslJsStream (options) {
3231
this.compiler = GLSL(options).compiler;
3332
};
3433

35-
inherits(GlslJsStream, Transform);
34+
inherits(GlslTranspilerStream, Transform);
3635

3736

3837
// glsl-parser streams data for each token from the glsl-tokenizer,
3938
// it generates lots of duplicated ASTs, which does not make any sense in the output.
4039
// So the satisfactory behaviour here is to render each statement in turn.
41-
GlslJsStream.prototype._transform = function (chunk, enc, cb) {
40+
GlslTranspilerStream.prototype._transform = function (chunk, enc, cb) {
4241
//if string passed - tokenize and parse it
4342
if (typeof chunk === 'string') {
4443
//FIXME: there is a problem of invalid input chunks; gotta wait till some sensible thing is accumulated and then parse.
@@ -76,4 +75,4 @@ GlslJsStream.prototype._transform = function (chunk, enc, cb) {
7675
}
7776
};
7877

79-
module.exports = GlslJsStream;
78+
export default GlslTranspilerStream;

test/api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import GLSL from '../index.js'
33
import TokenStream from 'glsl-tokenizer/stream.js'
44
import ParseStream from 'glsl-parser/stream.js'
5-
import CompileStream from '../stream.cjs'
5+
import CompileStream from '../stream.js'
66
import test from 'tape'
77
import StringStream from 'stream-array'
88
import { Writable } from 'stream'

0 commit comments

Comments
 (0)