@haelp/teto
Version:
A typescript-based controllable TETR.IO client.
1 lines • 2.26 kB
Source Map (JSON)
{"version":3,"sources":["../../../src/utils/theorypack/index.ts"],"sourcesContent":["import { Packr, Unpackr, addExtension } from \"./ts-wrap\";\n\n// require theorypack extensions\naddExtension({\n Class: undefined!,\n type: 1,\n read: (e) => (null === e ? { success: true } : { success: true, ...e })\n});\n\naddExtension({\n Class: undefined!,\n type: 2,\n read: (e) => (null === e ? { success: false } : { success: false, error: e })\n});\n\nconst unpacker = new Unpackr({\n int64AsType: \"number\",\n bundleStrings: true,\n sequential: false\n});\n\nconst packer = new Packr({\n int64AsType: \"number\",\n bundleStrings: true,\n sequential: false\n});\n\nexport namespace pack {\n /** unpack a single theorypack message */\n export const unpack = unpacker.unpack.bind(\n unpacker\n ) as typeof unpacker.unpack;\n /** unpack multiple theorypack messages */\n export const unpackMultiple = unpacker.unpackMultiple.bind(\n unpacker\n ) as typeof unpacker.unpackMultiple;\n /** decode a theorypack message */\n export const decode = packer.decode.bind(unpacker) as typeof unpacker.decode;\n /** pack a single theorypack messages */\n export const pack = packer.pack.bind(packer) as typeof packer.pack;\n /** encode a theorypack message */\n export const encode = packer.encode.bind(packer) as typeof packer.encode;\n}\n"],"names":["Packr","Unpackr","addExtension","Class","undefined","type","read","e","success","error","unpacker","int64AsType","bundleStrings","sequential","packer","pack","unpack","bind","unpackMultiple","decode","encode"],"mappings":"AAAA,SAASA,KAAK,EAAEC,OAAO,EAAEC,YAAY,QAAQ,YAAY;AAEzD,gCAAgC;AAChCA,aAAa;IACXC,OAAOC;IACPC,MAAM;IACNC,MAAM,CAACC,IAAO,SAASA,IAAI;YAAEC,SAAS;QAAK,IAAI;YAAEA,SAAS;YAAM,GAAGD,CAAC;QAAC;AACvE;AAEAL,aAAa;IACXC,OAAOC;IACPC,MAAM;IACNC,MAAM,CAACC,IAAO,SAASA,IAAI;YAAEC,SAAS;QAAM,IAAI;YAAEA,SAAS;YAAOC,OAAOF;QAAE;AAC7E;AAEA,MAAMG,WAAW,IAAIT,QAAQ;IAC3BU,aAAa;IACbC,eAAe;IACfC,YAAY;AACd;AAEA,MAAMC,SAAS,IAAId,MAAM;IACvBW,aAAa;IACbC,eAAe;IACfC,YAAY;AACd;UAEiBE;SAEFC,SAASN,SAASM,MAAM,CAACC,IAAI,CACxCP;SAGWQ,iBAAiBR,SAASQ,cAAc,CAACD,IAAI,CACxDP;SAGWS,SAASL,OAAOK,MAAM,CAACF,IAAI,CAACP;SAE5BK,OAAOD,OAAOC,IAAI,CAACE,IAAI,CAACH;SAExBM,SAASN,OAAOM,MAAM,CAACH,IAAI,CAACH;AAC3C,GAfiBC,SAAAA"}