How to use the restructure.Array function in restructure

To help you get started, we’ve selected a few restructure examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github foliojs / fontkit / src / tables / VDMX.js View on Github external
yMax:           r.int16,                             // Maximum value (in pels) for this yPelHeight
  yMin:           r.int16                              // Minimum value (in pels) for this yPelHeight
});

let VdmxGroup = new r.Struct({
  recs:           r.uint16,                            // Number of height records in this group
  startsz:        r.uint8,                             // Starting yPelHeight
  endsz:          r.uint8,                             // Ending yPelHeight
  entries:        new r.Array(vTable, 'recs')          // The VDMX records
});

export default new r.Struct({
  version:        r.uint16,                            // Version number (0 or 1)
  numRecs:        r.uint16,                            // Number of VDMX groups present
  numRatios:      r.uint16,                            // Number of aspect ratio groupings
  ratioRanges:    new r.Array(Ratio, 'numRatios'),     // Ratio ranges
  offsets:        new r.Array(r.uint16, 'numRatios'),  // Offset to the VDMX group for this ratio range
  groups:         new r.Array(VdmxGroup, 'numRecs')    // The actual VDMX groupings
});
github foliojs / fontkit / src / tables / GPOS.js View on Github external
let EntryExitRecord = new r.Struct({
  entryAnchor:    new r.Pointer(r.uint16, Anchor, {type: 'parent'}),
  exitAnchor:     new r.Pointer(r.uint16, Anchor, {type: 'parent'})
});

let MarkRecord = new r.Struct({
  class:      r.uint16,
  markAnchor: new r.Pointer(r.uint16, Anchor, {type: 'parent'})
});

let MarkArray = new r.Array(MarkRecord, r.uint16);

let BaseRecord  = new r.Array(new r.Pointer(r.uint16, Anchor), t => t.parent.classCount);
let BaseArray   = new r.Array(BaseRecord, r.uint16);

let ComponentRecord = new r.Array(new r.Pointer(r.uint16, Anchor), t => t.parent.parent.classCount);
let LigatureAttach  = new r.Array(ComponentRecord, r.uint16);
let LigatureArray   = new r.Array(new r.Pointer(r.uint16, LigatureAttach), r.uint16);

let GPOSLookup = new r.VersionedStruct('lookupType', {
  1: new r.VersionedStruct(r.uint16, { // Single Adjustment
    1: { // Single positioning value
      coverage:       new r.Pointer(r.uint16, Coverage),
      valueFormat:    ValueFormat,
      value:          new ValueRecord()
    },
    2: {
      coverage:       new r.Pointer(r.uint16, Coverage),
      valueFormat:    ValueFormat,
      valueCount:     r.uint16,
      values:         new r.LazyArray(new ValueRecord(), 'valueCount')
    }
github foliojs / fontkit / src / tables / BASE.js View on Github external
minCoord:           new r.Pointer(r.uint16, BaseCoord),  // May be NULL
  maxCoord:           new r.Pointer(r.uint16, BaseCoord),  // May be NULL
  featMinMaxCount:    r.uint16,                            // May be 0
  featMinMaxRecords:  new r.Array(FeatMinMaxRecord, 'featMinMaxCount') // In alphabetical order
});

let BaseLangSysRecord = new r.Struct({
  tag:    new r.String(4),  // 4-byte language system identification tag
  minMax: new r.Pointer(r.uint16, MinMax, {type: 'parent'})
});

let BaseScript = new r.Struct({
  baseValues:         new r.Pointer(r.uint16, BaseValues), // May be NULL
  defaultMinMax:      new r.Pointer(r.uint16, MinMax),     // May be NULL
  baseLangSysCount:   r.uint16,                            // May be 0
  baseLangSysRecords: new r.Array(BaseLangSysRecord, 'baseLangSysCount') // in alphabetical order by BaseLangSysTag
});

let BaseScriptRecord = new r.Struct({
  tag:      new r.String(4),  // 4-byte script identification tag
  script:   new r.Pointer(r.uint16, BaseScript, {type: 'parent'})
});

let BaseScriptList = new r.Array(BaseScriptRecord, r.uint16);

// Array of 4-byte baseline identification tags-must be in alphabetical order
let BaseTagList = new r.Array(new r.String(4), r.uint16);

let Axis = new r.Struct({
  baseTagList:    new r.Pointer(r.uint16, BaseTagList),  // May be NULL
  baseScriptList: new r.Pointer(r.uint16, BaseScriptList)
});
github foliojs / fontkit / src / tables / bsln.js View on Github external
deltas: new r.Array(r.int16, 32)
  },

  1: { // Distance-based, with mapping
    deltas: new r.Array(r.int16, 32),
    mappingData: new LookupTable(r.uint16)
  },

  2: { // Control point-based, no mapping
    standardGlyph: r.uint16,
    controlPoints: new r.Array(r.uint16, 32)
  },

  3: { // Control point-based, with mapping
    standardGlyph: r.uint16,
    controlPoints: new r.Array(r.uint16, 32),
    mappingData: new LookupTable(r.uint16)
  }
});

export default new r.Struct({
  version: r.fixed32,
  format: r.uint16,
  defaultBaseline: r.uint16,
  subtable: BslnSubtable
});
github wowserhq / blizzardry / src / lib / dbc / entities / light-float-band.js View on Github external
import r from 'restructure';

import Entity from '../entity';

export default Entity({
  id: r.uint32le,
  entryCount: r.uint32le,
  times: new r.Array(r.uint32le, 16),
  values: new r.Array(r.floatle, 16),
});
github wowserhq / blizzardry / lib / chunked / mwmo.js View on Github external
'use strict';

var r = require('restructure');
var Chunk = require('./chunk');

module.exports = Chunk({
  filenames: new r.Array(new r.String(null), 'size', 'bytes')
});
github wowserhq / blizzardry / src / lib / dbc / entities / item-extended-cost.js View on Github external
import r from 'restructure';

import Entity from '../entity';

export default Entity({
  id: r.uint32le,
  costHonor: r.uint32le,
  costArena: r.uint32le,
  itemIDs: new r.Array(r.uint32le, 5),
  itemCounts: new r.Array(r.uint32le, 5),
  personalRating: r.uint32le,
  purchaseGroupID: r.uint32le,
  unknown: new r.Reserved(r.uint32le),
});
github wowserhq / blizzardry / src / lib / wmo / group.js View on Github external
});

const MOBA = Chunk({
  batches: new r.Array(new r.Struct({
    skips: new r.Reserved(r.int16le, 2 * 3),
    firstIndex: r.uint32le,
    indexCount: r.uint16le,
    firstVertex: r.uint16le,
    lastVertex: r.uint16le,
    skip: new r.Reserved(r.uint8),
    materialID: r.uint8,
  }), 'size', 'bytes'),
});

const MODR = Chunk({
  doodadIndices: new r.Array(r.int16le, 'size', 'bytes'),
});

export default Chunked({
  MOGP: MOGP,
  MOPY: MOPY,
  MOVI: MOVI,
  MOVT: MOVT,
  MONR: MONR,
  MOTV: MOTV,
  MOBA: MOBA,

  flags: function () {
    return this.MOGP.flags;
  },

  MOLR: new r.Optional(SkipChunk, function () {
github wowserhq / blizzardry / src / lib / adt / index.js View on Github external
const MCVT = Chunk({
  heights: new r.Array(r.floatle, 145),
});

const MCNR = Chunk({
  normals: new r.Array(new r.Struct({
    x: r.int8,
    z: r.int8,
    y: r.int8,
  }), 145),
  skip: new r.Reserved(r.uint8, 13),
});

const MCLY = Chunk({
  layers: new r.Array(new r.Struct({
    textureID: r.uint32le,
    flags: r.uint32le,
    offsetMCAL: r.uint32le,
    effectID: r.int16le,
    skip: r.int16le,

    compressed: function () {
      return this.flags & 0x200;
    },
  }), 'size', 'bytes'),
});

const MCRF = Chunk({
  MDDFs: new r.Array(r.uint32le, function () {
    return this.parent.doodadCount;
  }),
github wowserhq / blizzardry / src / lib / dbc / entities / cinematic-sequences.js View on Github external
import r from 'restructure';

import Entity from '../entity';

export default Entity({
  id: r.uint32le,
  soundID: r.uint32le,
  cameraIDs: new r.Array(r.uint32le, 8),
});