+var Atom = function(buffer, offset) {
+ this.size = 0;
+ this.type = '';
+ this.childAtoms = [];
+
+ return this.parse(buffer, offset)
+};
+
+Atom.prototype.parse = function(buffer, offset)
+{
+ // 'offset' is optional.
+ if (arguments.length < 2)
+ offset = 0;
+
+ // Atoms are 8 bytes minimum.
+ if (buffer.byteLength - offset < 8)
+ return null;
+
+ var view = new DataView(buffer, offset, 4);
+ this.size = view.getUint32(0);
+
+ var typeArrayView = new Uint8Array(buffer, offset + 4, 4);
+ this.type = String.fromCharCode.apply(null, typeArrayView);
+
+ return this;
+};
\ No newline at end of file