@litert/redis
Version:
A redis protocol implement for Node.js.
94 lines • 2.91 kB
JavaScript
;
/**
* Copyright 2025 Angus.Fenying <fenying@litert.org>
*
* 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
*
* https://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.nullableBuffer2String = nullableBuffer2String;
exports.buffer2String = buffer2String;
exports.pairList2BufferDict = pairList2BufferDict;
exports.pairList2NullableBufferDict = pairList2NullableBufferDict;
exports.pairList2StringDict = pairList2StringDict;
exports.pairList2NullableStringDict = pairList2NullableStringDict;
exports.list2NullableBufferDict = list2NullableBufferDict;
exports.list2NullableStringDict = list2NullableStringDict;
exports.list2StringList = list2StringList;
exports.list2BufferList = list2BufferList;
function nullableBuffer2String(data) {
return data ? data.toString() : null;
}
function buffer2String(data) {
return data.toString();
}
function pairList2BufferDict(data) {
const ret = {};
if (!data) {
return ret;
}
for (let i = 0; i < data.length; i += 2) {
ret[data[i][1].toString()] = data[i + 1][1];
}
return ret;
}
function pairList2NullableBufferDict(data) {
const ret = {};
if (!data) {
return ret;
}
for (let i = 0; i < data.length; i += 2) {
ret[data[i][1].toString()] = data[i + 1][1];
}
return ret;
}
function pairList2StringDict(data) {
const ret = {};
if (!data) {
return ret;
}
for (let i = 0; i < data.length; i += 2) {
ret[data[i][1].toString()] = data[i + 1][1].toString();
}
return ret;
}
function pairList2NullableStringDict(data) {
const ret = {};
if (!data) {
return ret;
}
for (let i = 0; i < data.length; i += 2) {
ret[data[i][1].toString()] = data[i + 1][1] ? data[i + 1][1].toString() : null;
}
return ret;
}
function list2NullableBufferDict(keys, data) {
const ret = {};
for (let i = 0; i < data.length; i++) {
ret[keys[i]] = data[i][1];
}
return ret;
}
function list2NullableStringDict(keys, data) {
const ret = {};
for (let i = 0; i < data.length; i++) {
ret[keys[i]] = data[i][1] ? data[i][1].toString() : null;
}
return ret;
}
function list2StringList(data) {
return data ? data.map((x) => x[1].toString()) : [];
}
function list2BufferList(data) {
return data ? data.map((x) => x[1]) : [];
}
//# sourceMappingURL=Utils.js.map