1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.lset = lset;
|
7 | function lset(key, i, value) {
|
8 | if (!this.data.has(key)) {
|
9 | throw new Error('no such key');
|
10 | }
|
11 |
|
12 | if (this.data.has(key) && !(this.data.get(key) instanceof Array)) {
|
13 | throw new Error('Key ' + key + ' does not contain a list');
|
14 | }
|
15 |
|
16 | var index = parseInt(i, 10);
|
17 | var list = this.data.get(key) || [];
|
18 | list[index < 0 ? list.length + index : index] = value;
|
19 | this.data.set(key, list);
|
20 |
|
21 | return 'OK';
|
22 | } |
\ | No newline at end of file |