Skip to content

Commit 44584a5

Browse files
author
Sjoerd Tieleman
authored
Merge pull request #30 from Orange-OpenSource/grunt-preprocess-write
Grunt preprocess
2 parents bb78b52 + c688bfd commit 44584a5

File tree

5 files changed

+21
-12
lines changed

5 files changed

+21
-12
lines changed

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports = function(grunt) {
33
var boxes = grunt.option('boxes');
44

55
function includeWriteFunctions() {
6-
return (grunt.option('write') !== false);
6+
return (grunt.option('writing') !== false);
77
}
88

99
function getDestinationFile() {

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,15 @@ Please note, for size concerns, tests are only included in the Github repository
165165

166166
## Advanced build options
167167

168+
### Writing functionality
169+
170+
By default, `codem-isoboxer` build file contains all the code that manages the parsing AND the writing functionalities.
171+
If you are only interested in the parsing functionality, you can generate a build without writing functionality. The syntax for building is:
172+
173+
grunt --no-writing
174+
175+
### Modular build
176+
168177
`codem-isoboxer` now has the option for modular builds. This means you can specify which boxes you are interested in during build time and you will get a generated file containing only the necessary boxes. This can help you further decrease the size of the library if you know you will only need access to some boxes. The syntax for building is:
169178

170179
grunt --boxes=moov,mdat

src/iso_box.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ISOBox.prototype._procField = function (name, type, size) {
3131
if (this._parsing) {
3232
this[name] = this._readField(type, size);
3333
}
34-
// @ifdef WRITE
34+
// @if WRITE
3535
else {
3636
this._writeField(type, size, this[name]);
3737
}
@@ -46,7 +46,7 @@ ISOBox.prototype._procFieldArray = function (name, length, type, size) {
4646
this[name][i] = this._readField(type, size);
4747
}
4848
}
49-
// @ifdef WRITE
49+
// @if WRITE
5050
else {
5151
for (i = 0; i < this[name].length; i++) {
5252
this._writeField(type, size, this[name][i]);
@@ -69,7 +69,7 @@ ISOBox.prototype._procEntries = function(name, length, fn) {
6969
fn.call(this, this[name][i]);
7070
}
7171
}
72-
// @ifdef WRITE
72+
// @if WRITE
7373
else {
7474
for (i = 0; i < length; i++) {
7575
fn.call(this, this[name][i]);
@@ -87,7 +87,7 @@ ISOBox.prototype._procSubEntries = function(entry, name, length, fn) {
8787
fn.call(this, entry[name][i]);
8888
}
8989
}
90-
// @ifdef WRITE
90+
// @if WRITE
9191
else {
9292
for (i = 0; i < length; i++) {
9393
fn.call(this, entry[name][i]);
@@ -100,7 +100,7 @@ ISOBox.prototype._procEntryField = function (entry, name, type, size) {
100100
if (this._parsing) {
101101
entry[name] = this._readField(type, size);
102102
}
103-
// @ifdef WRITE
103+
// @if WRITE
104104
else {
105105
this._writeField(type, size, entry[name]);
106106
}
@@ -115,7 +115,7 @@ ISOBox.prototype._procSubBoxes = function(name, length) {
115115
this[name].push(ISOBox.parse(this));
116116
}
117117
}
118-
// @ifdef WRITE
118+
// @if WRITE
119119
else {
120120
for (i = 0; i < length; i++) {
121121
if (this._rawo) {
@@ -306,7 +306,7 @@ ISOBox.prototype._parseContainerBox = function() {
306306
}
307307
};
308308

309-
// @ifdef WRITE
309+
// @if WRITE
310310
///////////////////////////////////////////////////////////////////////////////////////////////////
311311
// Write functions
312312

src/iso_boxer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ISOBoxer.addBoxProcessor = function(type, parser) {
1111
ISOBox.prototype._boxProcessors[type] = parser;
1212
};
1313

14-
// @ifdef WRITE
14+
// @if WRITE
1515
ISOBoxer.createFile = function() {
1616
return new ISOFile();
1717
};
@@ -78,7 +78,7 @@ ISOBoxer.Utils.dataViewToString = function(dataView, encoding) {
7878
return a.join('');
7979
};
8080

81-
// @ifdef WRITE
81+
// @if WRITE
8282
ISOBoxer.Utils.utf8ToByteArray = function(string) {
8383
// Only UTF-8 encoding is supported by TextEncoder
8484
var u, i;
@@ -159,7 +159,7 @@ ISOBoxer.Utils.appendBox = function(parent, box, pos) {
159159
if (typeof exports !== 'undefined') {
160160
exports.parseBuffer = ISOBoxer.parseBuffer;
161161
exports.addBoxProcessor = ISOBoxer.addBoxProcessor;
162-
// @ifdef WRITE
162+
// @if WRITE
163163
exports.createFile = ISOBoxer.createFile;
164164
exports.createBox = ISOBoxer.createBox;
165165
exports.createFullBox = ISOBoxer.createFullBox;

src/iso_file.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ISOFile._sweep = function(type, result, returnEarly) {
3939
}
4040
};
4141

42-
// @ifdef WRITE
42+
// @if WRITE
4343
ISOFile.prototype.write = function() {
4444

4545
var length = 0,

0 commit comments

Comments
 (0)