Skip to content

Commit 649963f

Browse files
committed
MLE-23505 : jsDoc for vector-util.js is missing
1 parent 4601e92 commit 649963f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

lib/vector-util.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@
55
'use strict';
66
const { Buffer } = require('buffer');
77

8+
/**
9+
* Provides functions to encode and decode vectors.
10+
* MarkLogic 12 or higher needed.
11+
* @namespace vectorUtil
12+
*/
13+
14+
/**
15+
* Converts an array of vector float values into an encoded string.
16+
* Encoding vectors before writing them to documents in MarkLogic 12
17+
* helps reduce the amount of disk space and memory consumed by vectors.
18+
* @method vectorUtil#base64Encode
19+
* @since 3.7.0
20+
* @param {float[]} vector - an array of float values
21+
* @returns {string} an encoded string value.
22+
*/
823
const base64Encode = (vector) => {
924
const dimensions = vector.length;
1025
const buffer = Buffer.alloc(8 + 4 * dimensions);
@@ -19,6 +34,13 @@ const base64Encode = (vector) => {
1934
return buffer.toString('base64');
2035
};
2136

37+
/**
38+
* Converts an encoded string value to an array of vectors.
39+
* @method vectorUtil#base64Decode
40+
* @since 3.7.0
41+
* @param {string} encodedVector - an encoded string value.
42+
* @returns {float[]} an array of float values.
43+
*/
2244
const base64Decode = (encodedVector) => {
2345

2446
const buffer = Buffer.from(encodedVector, 'base64');

0 commit comments

Comments
 (0)