@@ -320,6 +320,25 @@ function factory( fields ) {
320
320
return layoutFormat ( FIELDS ) ;
321
321
} ) ;
322
322
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
+
323
342
/**
324
343
* Returns the length, in bytes, of the value specified by the provided field name.
325
344
*
@@ -383,46 +402,6 @@ function factory( fields ) {
383
402
return FIELDS [ idx ] . description ;
384
403
} ) ;
385
404
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
-
426
405
/**
427
406
* Returns a boolean indicating whether a provided value is a `struct` instance.
428
407
*
@@ -444,6 +423,27 @@ function factory( fields ) {
444
423
) ;
445
424
} ) ;
446
425
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
+
447
447
/**
448
448
* Returns the underlying byte buffer of a `struct` as a `DataView`.
449
449
*
@@ -493,7 +493,7 @@ function factory( fields ) {
493
493
} else {
494
494
opts = { } ;
495
495
}
496
- return struct2string ( this , FIELDS , opts ) ;
496
+ return struct2string ( Struct , FIELDS , opts ) ;
497
497
} ) ;
498
498
499
499
/**
0 commit comments