/
opt
/
canhelp
/
node_modules
/
gel
/
dist
/
codecs
/
/opt/canhelp/node_modules/gel/dist/codecs
mkdir
upload
Name
Size
Mode
Actions
array.d.ts
1274
0644
edit
dl
rm
array.js
3997
0644
edit
dl
rm
boolean.d.ts
1075
0644
edit
dl
rm
boolean.js
1425
0644
edit
dl
rm
bytes.d.ts
1076
0644
edit
dl
rm
bytes.js
1386
0644
edit
dl
rm
codecs.d.ts
5065
0644
edit
dl
rm
codecs.js
4047
0644
edit
dl
rm
consts.d.ts
955
0644
edit
dl
rm
consts.js
3433
0644
edit
dl
rm
context.d.ts
994
0644
edit
dl
rm
context.js
2549
0644
edit
dl
rm
datetime.d.ts
2817
0644
edit
dl
rm
datetime.js
13899
0644
edit
dl
rm
enum.d.ts
938
0644
edit
dl
rm
enum.js
1025
0644
edit
dl
rm
ifaces.d.ts
1941
0644
edit
dl
rm
ifaces.js
1830
0644
edit
dl
rm
json.d.ts
1416
0644
edit
dl
rm
json.js
3161
0644
edit
dl
rm
memory.d.ts
1105
0644
edit
dl
rm
memory.js
1938
0644
edit
dl
rm
namedtuple.d.ts
1315
0644
edit
dl
rm
namedtuple.js
3733
0644
edit
dl
rm
numbers.d.ts
1940
0644
edit
dl
rm
numbers.js
3600
0644
edit
dl
rm
numerics.d.ts
1300
0644
edit
dl
rm
numerics.js
5916
0644
edit
dl
rm
object.d.ts
1732
0644
edit
dl
rm
object.js
6173
0644
edit
dl
rm
pgvector.d.ts
1695
0644
edit
dl
rm
pgvector.js
6912
0644
edit
dl
rm
postgis.d.ts
778
0644
edit
dl
rm
postgis.js
13128
0644
edit
dl
rm
range.d.ts
1737
0644
edit
dl
rm
range.js
6039
0644
edit
dl
rm
record.d.ts
1509
0644
edit
dl
rm
record.js
3822
0644
edit
dl
rm
registry.d.ts
1083
0644
edit
dl
rm
registry.js
14687
0644
edit
dl
rm
set.d.ts
1244
0644
edit
dl
rm
set.js
3664
0644
edit
dl
rm
sparseObject.d.ts
1248
0644
edit
dl
rm
sparseObject.js
3040
0644
edit
dl
rm
text.d.ts
1074
0644
edit
dl
rm
text.js
1499
0644
edit
dl
rm
tuple.d.ts
1633
0644
edit
dl
rm
tuple.js
4790
0644
edit
dl
rm
uuid.d.ts
1075
0644
edit
dl
rm
uuid.js
2479
0644
edit
dl
rm
Edit:
/opt/canhelp/node_modules/gel/dist/codecs/tuple.js
(4790B)
"use strict"; /*! * This source file is part of the Gel open source project. * * Copyright 2019-present MagicStack Inc. and the Gel authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.EMPTY_TUPLE_CODEC = exports.EMPTY_TUPLE_CODEC_ID = exports.EmptyTupleCodec = exports.TupleCodec = void 0; const consts_1 = require("./consts"); const ifaces_1 = require("./ifaces"); const buffer_1 = require("../primitives/buffer"); const errors_1 = require("../errors"); class TupleCodec extends ifaces_1.Codec { subCodecs; typeName; constructor(tid, typeName, codecs) { super(tid); this.subCodecs = codecs; this.typeName = typeName; } encode(buf, object, ctx) { if (!Array.isArray(object)) { throw new errors_1.InvalidArgumentError(`an array was expected, got "${object}"`); } const codecs = this.subCodecs; const codecsLen = codecs.length; if (object.length !== codecsLen) { throw new errors_1.InvalidArgumentError(`expected ${codecsLen} tuple item${codecsLen === 1 ? "" : "s"}, got ${object.length}`); } if (!codecsLen) { buf.writeBuffer(EmptyTupleCodec.BUFFER); } const elemData = new buffer_1.WriteBuffer(); for (let i = 0; i < codecsLen; i++) { const elem = object[i]; elemData.writeInt32(0); if (elem == null) { throw new errors_1.MissingArgumentError(`element at index ${i} in tuple cannot be 'null'`); } else { try { codecs[i].encode(elemData, elem, ctx); } catch (e) { if (e instanceof errors_1.QueryArgumentError) { throw new errors_1.InvalidArgumentError(`invalid element at index ${i} in tuple: ${e.message}`); } else { throw e; } } } } const elemBuf = elemData.unwrap(); buf.writeInt32(4 + elemBuf.length); buf.writeInt32(codecsLen); buf.writeBuffer(elemBuf); } decode(buf, ctx) { const els = buf.readUInt32(); const subCodecs = this.subCodecs; if (els !== subCodecs.length) { throw new errors_1.ProtocolError(`cannot decode Tuple: expected ` + `${subCodecs.length} elements, got ${els}`); } const elemBuf = buffer_1.ReadBuffer.alloc(); const result = new Array(els); for (let i = 0; i < els; i++) { buf.discard(4); const elemLen = buf.readInt32(); if (elemLen === -1) { result[i] = null; } else { buf.sliceInto(elemBuf, elemLen); result[i] = subCodecs[i].decode(elemBuf, ctx); elemBuf.finish(); } } return result; } getSubcodecs() { return Array.from(this.subCodecs); } getKind() { return "tuple"; } } exports.TupleCodec = TupleCodec; class EmptyTupleCodec extends ifaces_1.Codec { static BUFFER = new buffer_1.WriteBuffer() .writeInt32(4) .writeInt32(0) .unwrap(); encode(buf, object, _ctx) { if (!Array.isArray(object)) { throw new errors_1.InvalidArgumentError("cannot encode empty Tuple: expected an array"); } if (object.length) { throw new errors_1.InvalidArgumentError(`cannot encode empty Tuple: expected 0 elements got ${object.length}`); } buf.writeInt32(4); buf.writeInt32(0); } decode(buf) { const els = buf.readInt32(); if (els !== 0) { throw new errors_1.ProtocolError(`cannot decode empty Tuple: expected 0 elements, received ${els}`); } return []; } getSubcodecs() { return []; } getKind() { return "tuple"; } } exports.EmptyTupleCodec = EmptyTupleCodec; exports.EMPTY_TUPLE_CODEC_ID = consts_1.KNOWN_TYPENAMES.get("empty-tuple"); exports.EMPTY_TUPLE_CODEC = new EmptyTupleCodec(exports.EMPTY_TUPLE_CODEC_ID);
Save
cmd:
run