Skip to content

Commit

Permalink
Merge pull request #30 from Orange-OpenSource/grunt-preprocess-write
Browse files Browse the repository at this point in the history
Grunt preprocess
  • Loading branch information
Sjoerd Tieleman authored Jun 16, 2017
2 parents bb78b52 + c688bfd commit 44584a5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = function(grunt) {
var boxes = grunt.option('boxes');

function includeWriteFunctions() {
return (grunt.option('write') !== false);
return (grunt.option('writing') !== false);
}

function getDestinationFile() {
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@ Please note, for size concerns, tests are only included in the Github repository

## Advanced build options

### Writing functionality

By default, `codem-isoboxer` build file contains all the code that manages the parsing AND the writing functionalities.
If you are only interested in the parsing functionality, you can generate a build without writing functionality. The syntax for building is:

grunt --no-writing

### Modular build

`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:

grunt --boxes=moov,mdat
Expand Down
14 changes: 7 additions & 7 deletions src/iso_box.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ISOBox.prototype._procField = function (name, type, size) {
if (this._parsing) {
this[name] = this._readField(type, size);
}
// @ifdef WRITE
// @if WRITE
else {
this._writeField(type, size, this[name]);
}
Expand All @@ -46,7 +46,7 @@ ISOBox.prototype._procFieldArray = function (name, length, type, size) {
this[name][i] = this._readField(type, size);
}
}
// @ifdef WRITE
// @if WRITE
else {
for (i = 0; i < this[name].length; i++) {
this._writeField(type, size, this[name][i]);
Expand All @@ -69,7 +69,7 @@ ISOBox.prototype._procEntries = function(name, length, fn) {
fn.call(this, this[name][i]);
}
}
// @ifdef WRITE
// @if WRITE
else {
for (i = 0; i < length; i++) {
fn.call(this, this[name][i]);
Expand All @@ -87,7 +87,7 @@ ISOBox.prototype._procSubEntries = function(entry, name, length, fn) {
fn.call(this, entry[name][i]);
}
}
// @ifdef WRITE
// @if WRITE
else {
for (i = 0; i < length; i++) {
fn.call(this, entry[name][i]);
Expand All @@ -100,7 +100,7 @@ ISOBox.prototype._procEntryField = function (entry, name, type, size) {
if (this._parsing) {
entry[name] = this._readField(type, size);
}
// @ifdef WRITE
// @if WRITE
else {
this._writeField(type, size, entry[name]);
}
Expand All @@ -115,7 +115,7 @@ ISOBox.prototype._procSubBoxes = function(name, length) {
this[name].push(ISOBox.parse(this));
}
}
// @ifdef WRITE
// @if WRITE
else {
for (i = 0; i < length; i++) {
if (this._rawo) {
Expand Down Expand Up @@ -306,7 +306,7 @@ ISOBox.prototype._parseContainerBox = function() {
}
};

// @ifdef WRITE
// @if WRITE
///////////////////////////////////////////////////////////////////////////////////////////////////
// Write functions

Expand Down
6 changes: 3 additions & 3 deletions src/iso_boxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ISOBoxer.addBoxProcessor = function(type, parser) {
ISOBox.prototype._boxProcessors[type] = parser;
};

// @ifdef WRITE
// @if WRITE
ISOBoxer.createFile = function() {
return new ISOFile();
};
Expand Down Expand Up @@ -78,7 +78,7 @@ ISOBoxer.Utils.dataViewToString = function(dataView, encoding) {
return a.join('');
};

// @ifdef WRITE
// @if WRITE
ISOBoxer.Utils.utf8ToByteArray = function(string) {
// Only UTF-8 encoding is supported by TextEncoder
var u, i;
Expand Down Expand Up @@ -159,7 +159,7 @@ ISOBoxer.Utils.appendBox = function(parent, box, pos) {
if (typeof exports !== 'undefined') {
exports.parseBuffer = ISOBoxer.parseBuffer;
exports.addBoxProcessor = ISOBoxer.addBoxProcessor;
// @ifdef WRITE
// @if WRITE
exports.createFile = ISOBoxer.createFile;
exports.createBox = ISOBoxer.createBox;
exports.createFullBox = ISOBoxer.createFullBox;
Expand Down
2 changes: 1 addition & 1 deletion src/iso_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ISOFile._sweep = function(type, result, returnEarly) {
}
};

// @ifdef WRITE
// @if WRITE
ISOFile.prototype.write = function() {

var length = 0,
Expand Down

0 comments on commit 44584a5

Please sign in to comment.