@@ -320,6 +320,25 @@ function factory( fields ) {
320320 return layoutFormat ( FIELDS ) ;
321321 } ) ;
322322
323+ /**
324+ * Returns the underlying byte buffer of a `struct`.
325+ *
326+ * @private
327+ * @name bufferOf
328+ * @memberof Struct
329+ * @readonly
330+ * @type {Function }
331+ * @param {Object } obj - struct instance
332+ * @throws {TypeError } must provide a `struct` instance
333+ * @returns {ArrayBuffer } underlying byte buffer
334+ */
335+ setReadOnly ( Struct , 'bufferOf' , function bufferOf ( obj ) {
336+ if ( ! isStructInstance ( obj ) ) {
337+ throw new TypeError ( format ( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.' , obj ) ) ;
338+ }
339+ return obj [ PRIVATE_BUFFER ] . buffer ;
340+ } ) ;
341+
323342 /**
324343 * Returns the length, in bytes, of the value specified by the provided field name.
325344 *
@@ -383,46 +402,6 @@ function factory( fields ) {
383402 return FIELDS [ idx ] . description ;
384403 } ) ;
385404
386- /**
387- * Returns the type associated with a provided field name.
388- *
389- * @private
390- * @name typeOf
391- * @memberof Struct
392- * @readonly
393- * @type {Function }
394- * @param {string } name - field name
395- * @throws {Error } struct must have at least one field
396- * @throws {TypeError } must provide a recognized field name
397- * @returns {(string|Object) } type
398- */
399- setReadOnly ( Struct , 'typeOf' , function typeOf ( name ) {
400- var idx = fieldIndex ( FIELD_NAMES , name ) ;
401- if ( idx instanceof Error ) {
402- throw idx ;
403- }
404- return FIELDS [ idx ] . type ;
405- } ) ;
406-
407- /**
408- * Returns the underlying byte buffer of a `struct`.
409- *
410- * @private
411- * @name bufferOf
412- * @memberof Struct
413- * @readonly
414- * @type {Function }
415- * @param {Object } obj - struct instance
416- * @throws {TypeError } must provide a `struct` instance
417- * @returns {ArrayBuffer } underlying byte buffer
418- */
419- setReadOnly ( Struct , 'bufferOf' , function bufferOf ( obj ) {
420- if ( ! isStructInstance ( obj ) ) {
421- throw new TypeError ( format ( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.' , obj ) ) ;
422- }
423- return obj [ PRIVATE_BUFFER ] . buffer ;
424- } ) ;
425-
426405 /**
427406 * Returns a boolean indicating whether a provided value is a `struct` instance.
428407 *
@@ -444,6 +423,27 @@ function factory( fields ) {
444423 ) ;
445424 } ) ;
446425
426+ /**
427+ * Returns the type associated with a provided field name.
428+ *
429+ * @private
430+ * @name typeOf
431+ * @memberof Struct
432+ * @readonly
433+ * @type {Function }
434+ * @param {string } name - field name
435+ * @throws {Error } struct must have at least one field
436+ * @throws {TypeError } must provide a recognized field name
437+ * @returns {(string|Object) } type
438+ */
439+ setReadOnly ( Struct , 'typeOf' , function typeOf ( name ) {
440+ var idx = fieldIndex ( FIELD_NAMES , name ) ;
441+ if ( idx instanceof Error ) {
442+ throw idx ;
443+ }
444+ return FIELDS [ idx ] . type ;
445+ } ) ;
446+
447447 /**
448448 * Returns the underlying byte buffer of a `struct` as a `DataView`.
449449 *
@@ -493,7 +493,7 @@ function factory( fields ) {
493493 } else {
494494 opts = { } ;
495495 }
496- return struct2string ( this , FIELDS , opts ) ;
496+ return struct2string ( Struct , FIELDS , opts ) ;
497497 } ) ;
498498
499499 /**
0 commit comments