@ragestudio/scylla-odm 0.22.2 → 0.22.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/batch/index.d.ts +3 -3
- package/batch/index.d.ts.map +1 -1
- package/client.d.ts +6 -5
- package/client.d.ts.map +1 -1
- package/client.js +11 -12
- package/client.js.map +1 -1
- package/cql_gen/create_table.d.ts +1 -1
- package/cql_gen/create_table.d.ts.map +1 -1
- package/document/index.d.ts +3 -3
- package/document/index.d.ts.map +1 -1
- package/driver/LICENSE.txt +177 -0
- package/driver/NOTICE.txt +67 -0
- package/driver/auth/index.d.ts +37 -0
- package/driver/auth/index.js +37 -0
- package/driver/auth/no-auth-provider.js +73 -0
- package/driver/auth/plain-text-auth-provider.js +81 -0
- package/driver/auth/provider.js +77 -0
- package/driver/client-options.js +442 -0
- package/driver/client.js +1267 -0
- package/driver/concurrent/index.d.ts +49 -0
- package/driver/concurrent/index.js +366 -0
- package/driver/connection.js +1034 -0
- package/driver/control-connection.js +1282 -0
- package/driver/encoder.js +2316 -0
- package/driver/errors.js +223 -0
- package/driver/execution-options.js +612 -0
- package/driver/execution-profile.js +274 -0
- package/driver/host-connection-pool.js +587 -0
- package/driver/host.js +699 -0
- package/driver/index.d.ts +387 -0
- package/driver/index.js +81 -0
- package/driver/mapping/cache.js +214 -0
- package/driver/mapping/doc-info-adapter.js +171 -0
- package/driver/mapping/index.d.ts +219 -0
- package/driver/mapping/index.js +57 -0
- package/driver/mapping/mapper.js +225 -0
- package/driver/mapping/mapping-handler.js +641 -0
- package/driver/mapping/model-batch-item.js +215 -0
- package/driver/mapping/model-batch-mapper.js +141 -0
- package/driver/mapping/model-mapper.js +315 -0
- package/driver/mapping/model-mapping-info.js +225 -0
- package/driver/mapping/object-selector.js +417 -0
- package/driver/mapping/q.js +156 -0
- package/driver/mapping/query-generator.js +556 -0
- package/driver/mapping/result-mapper.js +123 -0
- package/driver/mapping/result.js +139 -0
- package/driver/mapping/table-mappings.js +133 -0
- package/driver/mapping/tree.js +160 -0
- package/driver/metadata/aggregate.js +79 -0
- package/driver/metadata/client-state.js +119 -0
- package/driver/metadata/data-collection.js +182 -0
- package/driver/metadata/event-debouncer.js +174 -0
- package/driver/metadata/index.d.ts +276 -0
- package/driver/metadata/index.js +1156 -0
- package/driver/metadata/materialized-view.js +49 -0
- package/driver/metadata/schema-function.js +98 -0
- package/driver/metadata/schema-index.js +166 -0
- package/driver/metadata/schema-parser.js +1399 -0
- package/driver/metadata/table-metadata.js +77 -0
- package/driver/operation-state.js +206 -0
- package/driver/policies/address-resolution.js +145 -0
- package/driver/policies/index.d.ts +241 -0
- package/driver/policies/index.js +110 -0
- package/driver/policies/load-balancing.js +970 -0
- package/driver/policies/reconnection.js +166 -0
- package/driver/policies/retry.js +326 -0
- package/driver/policies/speculative-execution.js +150 -0
- package/driver/policies/timestamp-generation.js +176 -0
- package/driver/prepare-handler.js +347 -0
- package/driver/promise-utils.js +191 -0
- package/driver/readers.js +624 -0
- package/driver/request-execution.js +644 -0
- package/driver/request-handler.js +332 -0
- package/driver/requests.js +618 -0
- package/driver/stream-id-stack.js +209 -0
- package/driver/streams.js +745 -0
- package/driver/token.js +325 -0
- package/driver/tokenizer.js +631 -0
- package/driver/types/big-decimal.js +282 -0
- package/driver/types/duration.js +576 -0
- package/driver/types/index.d.ts +486 -0
- package/driver/types/index.js +733 -0
- package/driver/types/inet-address.js +262 -0
- package/driver/types/integer.js +818 -0
- package/driver/types/local-date.js +280 -0
- package/driver/types/local-time.js +299 -0
- package/driver/types/mutable-long.js +385 -0
- package/driver/types/protocol-version.js +391 -0
- package/driver/types/result-set.js +287 -0
- package/driver/types/result-stream.js +164 -0
- package/driver/types/row.js +85 -0
- package/driver/types/time-uuid.js +414 -0
- package/driver/types/tuple.js +103 -0
- package/driver/types/uuid.js +160 -0
- package/driver/types/vector.js +130 -0
- package/driver/types/version-number.js +153 -0
- package/driver/utils.js +1485 -0
- package/driver/writers.js +350 -0
- package/global.d.ts +1 -1
- package/global.d.ts.map +1 -1
- package/index.d.ts +6 -6
- package/index.d.ts.map +1 -1
- package/index.js +6 -6
- package/index.js.map +1 -1
- package/migrate/index.d.ts +1 -1
- package/migrate/index.d.ts.map +1 -1
- package/migrate/index.js +1 -1
- package/migrate/index.js.map +1 -1
- package/model/index.d.ts +6 -6
- package/model/index.d.ts.map +1 -1
- package/model/index.js +10 -10
- package/model/index.js.map +1 -1
- package/operations/countAll.d.ts +1 -1
- package/operations/countAll.d.ts.map +1 -1
- package/operations/delete.d.ts +3 -4
- package/operations/delete.d.ts.map +1 -1
- package/operations/delete.js +1 -1
- package/operations/delete.js.map +1 -1
- package/operations/find.d.ts +2 -2
- package/operations/find.d.ts.map +1 -1
- package/operations/find.js +1 -1
- package/operations/find.js.map +1 -1
- package/operations/findOne.d.ts +2 -2
- package/operations/findOne.d.ts.map +1 -1
- package/operations/findOne.js +1 -1
- package/operations/findOne.js.map +1 -1
- package/operations/insert.d.ts +3 -3
- package/operations/insert.d.ts.map +1 -1
- package/operations/insert.js +2 -2
- package/operations/insert.js.map +1 -1
- package/operations/sync.d.ts +1 -1
- package/operations/sync.d.ts.map +1 -1
- package/operations/sync.js +1 -1
- package/operations/sync.js.map +1 -1
- package/operations/tableExists.d.ts +1 -1
- package/operations/tableExists.d.ts.map +1 -1
- package/operations/update.d.ts +3 -3
- package/operations/update.d.ts.map +1 -1
- package/operations/update.js +2 -2
- package/operations/update.js.map +1 -1
- package/package.json +4 -12
- package/schema/index.d.ts +1 -1
- package/schema/index.d.ts.map +1 -1
- package/types.d.ts +4 -4
- package/types.d.ts.map +1 -1
- package/utils/queryParser.d.ts +1 -1
- package/utils/queryParser.d.ts.map +1 -1
- package/utils/queryParser.js +1 -1
- package/utils/queryParser.js.map +1 -1
- package/utils/typeChecker.d.ts +1 -1
- package/utils/typeChecker.d.ts.map +1 -1
- package/utils/typeChecker.js +1 -1
- package/utils/typeChecker.js.map +1 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** @module types */
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new sequence of immutable objects with the parameters provided.
|
|
23
|
+
* @class
|
|
24
|
+
* @classdesc A tuple is a sequence of immutable objects.
|
|
25
|
+
* Tuples are sequences, just like [Arrays]{@link Array}. The only difference is that tuples can't be changed.
|
|
26
|
+
* <p>
|
|
27
|
+
* As tuples can be used as a Map keys, the {@link Tuple#toString toString()} method calls toString of each element,
|
|
28
|
+
* to try to get a unique string key.
|
|
29
|
+
* </p>
|
|
30
|
+
* @param args The sequence elements as arguments.
|
|
31
|
+
* @constructor
|
|
32
|
+
*/
|
|
33
|
+
function Tuple(...args) {
|
|
34
|
+
/**
|
|
35
|
+
* Immutable elements of Tuple object.
|
|
36
|
+
* @type Array
|
|
37
|
+
*/
|
|
38
|
+
this.elements = args
|
|
39
|
+
|
|
40
|
+
if (this.elements.length === 0) {
|
|
41
|
+
throw new TypeError("Tuple must contain at least one value")
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Returns the number of the elements.
|
|
46
|
+
* @type Number
|
|
47
|
+
*/
|
|
48
|
+
this.length = this.elements.length
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Creates a new instance of a tuple based on the Array
|
|
53
|
+
* @param {Array} elements
|
|
54
|
+
* @returns {Tuple}
|
|
55
|
+
*/
|
|
56
|
+
Tuple.fromArray = function (elements) {
|
|
57
|
+
// Apply the elements Array as parameters
|
|
58
|
+
return new Tuple(...elements)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Returns the value located at the index.
|
|
63
|
+
* @param {Number} index Element index
|
|
64
|
+
*/
|
|
65
|
+
Tuple.prototype.get = function (index) {
|
|
66
|
+
return this.elements[index || 0]
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Returns the string representation of the sequence surrounded by parenthesis, ie: (1, 2).
|
|
71
|
+
* <p>
|
|
72
|
+
* The returned value attempts to be a unique string representation of its values.
|
|
73
|
+
* </p>
|
|
74
|
+
* @returns {string}
|
|
75
|
+
*/
|
|
76
|
+
Tuple.prototype.toString = function () {
|
|
77
|
+
return (
|
|
78
|
+
"(" +
|
|
79
|
+
this.elements.reduce(function (prev, x, i) {
|
|
80
|
+
return prev + (i > 0 ? "," : "") + x.toString()
|
|
81
|
+
}, "") +
|
|
82
|
+
")"
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Returns the Array representation of the sequence.
|
|
88
|
+
* @returns {Array}
|
|
89
|
+
*/
|
|
90
|
+
Tuple.prototype.toJSON = function () {
|
|
91
|
+
return this.elements
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Gets the elements as an array
|
|
96
|
+
* @returns {Array}
|
|
97
|
+
*/
|
|
98
|
+
Tuple.prototype.values = function () {
|
|
99
|
+
// Clone the elements
|
|
100
|
+
return this.elements.slice(0)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export default Tuple
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import crypto from "crypto"
|
|
20
|
+
import utils from "../utils.js"
|
|
21
|
+
|
|
22
|
+
/** @module types */
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new instance of Uuid based on a Buffer
|
|
26
|
+
* @class
|
|
27
|
+
* @classdesc Represents an immutable universally unique identifier (UUID). A UUID represents a 128-bit value.
|
|
28
|
+
* @param {Buffer} buffer The 16-length buffer.
|
|
29
|
+
* @constructor
|
|
30
|
+
*/
|
|
31
|
+
function Uuid(buffer) {
|
|
32
|
+
if (!buffer || buffer.length !== 16) {
|
|
33
|
+
throw new Error("You must provide a buffer containing 16 bytes")
|
|
34
|
+
}
|
|
35
|
+
this.buffer = buffer
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Parses a string representation of a Uuid
|
|
40
|
+
* @param {String} value
|
|
41
|
+
* @returns {Uuid}
|
|
42
|
+
*/
|
|
43
|
+
Uuid.fromString = function (value) {
|
|
44
|
+
//36 chars: 32 + 4 hyphens
|
|
45
|
+
if (typeof value !== "string" || value.length !== 36) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
"Invalid string representation of Uuid, it should be in the 00000000-0000-0000-0000-000000000000",
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
return new Uuid(utils.allocBufferFromString(value.replace(/-/g, ""), "hex"))
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Creates a new random (version 4) Uuid.
|
|
55
|
+
* @param {function} [callback] Optional callback to be invoked with the error as first parameter and the created Uuid as
|
|
56
|
+
* second parameter.
|
|
57
|
+
* @returns {Uuid}
|
|
58
|
+
*/
|
|
59
|
+
Uuid.random = function (callback) {
|
|
60
|
+
if (callback) {
|
|
61
|
+
getRandomBytes(function (err, buffer) {
|
|
62
|
+
if (err) {
|
|
63
|
+
return callback(err)
|
|
64
|
+
}
|
|
65
|
+
return callback(null, createUuidFromBuffer(buffer))
|
|
66
|
+
})
|
|
67
|
+
} else {
|
|
68
|
+
const buffer = getRandomBytes()
|
|
69
|
+
return createUuidFromBuffer(buffer)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets the bytes representation of a Uuid
|
|
75
|
+
* @returns {Buffer}
|
|
76
|
+
*/
|
|
77
|
+
Uuid.prototype.getBuffer = function () {
|
|
78
|
+
return this.buffer
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Compares this object to the specified object.
|
|
82
|
+
* The result is true if and only if the argument is not null, is a UUID object, and contains the same value, bit for bit, as this UUID.
|
|
83
|
+
* @param {Uuid} other The other value to test for equality.
|
|
84
|
+
*/
|
|
85
|
+
Uuid.prototype.equals = function (other) {
|
|
86
|
+
return other instanceof Uuid && this.buffer.equals(other.buffer)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Returns a string representation of the value of this Uuid instance.
|
|
91
|
+
* 32 hex separated by hyphens, in the form of 00000000-0000-0000-0000-000000000000.
|
|
92
|
+
* @returns {String}
|
|
93
|
+
*/
|
|
94
|
+
Uuid.prototype.toString = function () {
|
|
95
|
+
//32 hex representation of the Buffer
|
|
96
|
+
const hexValue = getHex(this)
|
|
97
|
+
return (
|
|
98
|
+
hexValue.substr(0, 8) +
|
|
99
|
+
"-" +
|
|
100
|
+
hexValue.substr(8, 4) +
|
|
101
|
+
"-" +
|
|
102
|
+
hexValue.substr(12, 4) +
|
|
103
|
+
"-" +
|
|
104
|
+
hexValue.substr(16, 4) +
|
|
105
|
+
"-" +
|
|
106
|
+
hexValue.substr(20, 12)
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Provide the name of the constructor and the string representation
|
|
112
|
+
* @returns {string}
|
|
113
|
+
*/
|
|
114
|
+
Uuid.prototype.inspect = function () {
|
|
115
|
+
return this.constructor.name + ": " + this.toString()
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Returns the string representation.
|
|
120
|
+
* Method used by the native JSON.stringify() to serialize this instance.
|
|
121
|
+
*/
|
|
122
|
+
Uuid.prototype.toJSON = function () {
|
|
123
|
+
return this.toString()
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Returns new Uuid
|
|
128
|
+
* @private
|
|
129
|
+
* @returns {Uuid}
|
|
130
|
+
*/
|
|
131
|
+
function createUuidFromBuffer(buffer) {
|
|
132
|
+
//clear the version
|
|
133
|
+
buffer[6] &= 0x0f
|
|
134
|
+
//set the version 4
|
|
135
|
+
buffer[6] |= 0x40
|
|
136
|
+
//clear the variant
|
|
137
|
+
buffer[8] &= 0x3f
|
|
138
|
+
//set the IETF variant
|
|
139
|
+
buffer[8] |= 0x80
|
|
140
|
+
return new Uuid(buffer)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @private
|
|
145
|
+
* @returns {String} 32 hex representation of the instance, without separators
|
|
146
|
+
*/
|
|
147
|
+
function getHex(uuid) {
|
|
148
|
+
return uuid.buffer.toString("hex")
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Gets a crypto generated 16 bytes
|
|
153
|
+
* @private
|
|
154
|
+
* @returns {Buffer}
|
|
155
|
+
*/
|
|
156
|
+
function getRandomBytes(cb) {
|
|
157
|
+
return crypto.randomBytes(16, cb)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export default Uuid
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
/** @module types */
|
|
19
|
+
|
|
20
|
+
import util from "node:util"
|
|
21
|
+
|
|
22
|
+
class Vector {
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param {Float32Array | Array<any>} elements
|
|
26
|
+
* @param {string} [subtype]
|
|
27
|
+
*/
|
|
28
|
+
constructor(elements, subtype) {
|
|
29
|
+
if (elements instanceof Float32Array) {
|
|
30
|
+
this.elements = Array.from(elements)
|
|
31
|
+
} else if (Array.isArray(elements)) {
|
|
32
|
+
this.elements = elements
|
|
33
|
+
} else {
|
|
34
|
+
throw new TypeError(
|
|
35
|
+
"Vector must be constructed with a Float32Array or an Array",
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
if (this.elements.length === 0) {
|
|
39
|
+
throw new TypeError("Vector must contain at least one value")
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns the number of the elements.
|
|
43
|
+
* @type Number
|
|
44
|
+
*/
|
|
45
|
+
this.length = this.elements.length
|
|
46
|
+
this.subtype = subtype
|
|
47
|
+
return new Proxy(this, {
|
|
48
|
+
get: function (obj, key) {
|
|
49
|
+
if (key === "IDENTITY") {
|
|
50
|
+
return "Vector"
|
|
51
|
+
} else if (
|
|
52
|
+
typeof key === "string" &&
|
|
53
|
+
Number.isInteger(Number(key))
|
|
54
|
+
) // key is an index
|
|
55
|
+
{
|
|
56
|
+
return obj.elements[key]
|
|
57
|
+
}
|
|
58
|
+
return obj[key]
|
|
59
|
+
},
|
|
60
|
+
set: function (obj, key, value) {
|
|
61
|
+
if (
|
|
62
|
+
typeof key === "string" &&
|
|
63
|
+
Number.isInteger(Number(key))
|
|
64
|
+
) // key is an index
|
|
65
|
+
{
|
|
66
|
+
return (obj.elements[key] = value)
|
|
67
|
+
}
|
|
68
|
+
return (obj[key] = value)
|
|
69
|
+
},
|
|
70
|
+
ownKeys: function (obj) {
|
|
71
|
+
return Reflect.ownKeys(elements)
|
|
72
|
+
},
|
|
73
|
+
getOwnPropertyDescriptor(target, key) {
|
|
74
|
+
if (typeof key === "string" && Number.isInteger(Number(key))) {
|
|
75
|
+
// array index
|
|
76
|
+
return { enumerable: true, configurable: true }
|
|
77
|
+
}
|
|
78
|
+
return Reflect.getOwnPropertyDescriptor(target, key)
|
|
79
|
+
},
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Returns the string representation of the vector.
|
|
84
|
+
* @returns {string}
|
|
85
|
+
*/
|
|
86
|
+
toString() {
|
|
87
|
+
return "[".concat(this.elements.toString(), "]")
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
* @param {number} index
|
|
92
|
+
*/
|
|
93
|
+
at(index) {
|
|
94
|
+
return this.elements[index]
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
*
|
|
99
|
+
* @returns {IterableIterator<any>} an iterator over the elements of the vector
|
|
100
|
+
*/
|
|
101
|
+
[Symbol.iterator]() {
|
|
102
|
+
return this.elements[Symbol.iterator]()
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
static get [Symbol.species]() {
|
|
106
|
+
return Vector
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
forEach(callback) {
|
|
110
|
+
return this.elements.forEach(callback)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @returns {string | undefined} get the subtype string, e.g., "float", but it's optional so it can return undefined
|
|
115
|
+
*/
|
|
116
|
+
getSubtype() {
|
|
117
|
+
return this.subtype
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
Object.defineProperty(Vector, Symbol.hasInstance, {
|
|
122
|
+
value: function (i) {
|
|
123
|
+
return (
|
|
124
|
+
(util.types.isProxy(i) && i.IDENTITY === "Vector") ||
|
|
125
|
+
i instanceof Float32Array
|
|
126
|
+
)
|
|
127
|
+
},
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
export default Vector
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const _versionPattern =
|
|
20
|
+
/(\d+)\.(\d+)(?:\.(\d+))?(?:\.(\d+)?)?(?:[-~]([\w+]*(?:-\w[.\w]*)*))?(?:\+([.\w]+))?/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Represents a version number in the form of X.Y.Z with optional pre-release and build metadata.
|
|
24
|
+
*
|
|
25
|
+
* Version numbers compare the usual way, the major version number (X) is compared first, then
|
|
26
|
+
* the minor one (Y) and then the patch level one (Z). If pre-release or other build metadata
|
|
27
|
+
* is present for a version, that version is considered less than an otherwise equivalent version
|
|
28
|
+
* that doesn't have these labels, otherwise they are considered equal.
|
|
29
|
+
*
|
|
30
|
+
* As of initial implementation versions are only compared against those with at most patch versions
|
|
31
|
+
* more refined comparisons are not needed.
|
|
32
|
+
*
|
|
33
|
+
* @property {Number} major The major version, X of X.Y.Z.
|
|
34
|
+
* @property {Number} minor The minor version, Y of X.Y.Z.
|
|
35
|
+
* @property {Number} patch The patch version, Z of X.Y.Z.
|
|
36
|
+
* @property {Number} dsePatch The dsePatch version, A of X.Y.Z.A or undefined if not present.
|
|
37
|
+
* @property {String[]} preReleases Prerelease indicators if present, i.e. SNAPSHOT of X.Y.Z-SNAPSHOT.
|
|
38
|
+
* @property {String} build Build string if present, i.e. build1 of X.Y.Z+build1.
|
|
39
|
+
*
|
|
40
|
+
* @ignore
|
|
41
|
+
*/
|
|
42
|
+
class VersionNumber {
|
|
43
|
+
constructor(major, minor, patch, dsePatch, preReleases, build) {
|
|
44
|
+
this.major = major
|
|
45
|
+
this.minor = minor
|
|
46
|
+
this.patch = patch
|
|
47
|
+
this.dsePatch = dsePatch
|
|
48
|
+
this.preReleases = preReleases
|
|
49
|
+
this.build = build
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @return {String} String representation of this version.
|
|
54
|
+
*/
|
|
55
|
+
toString() {
|
|
56
|
+
let str = this.major + "." + this.minor
|
|
57
|
+
if (this.patch !== undefined) {
|
|
58
|
+
str += "." + this.patch
|
|
59
|
+
}
|
|
60
|
+
if (this.dsePatch !== undefined) {
|
|
61
|
+
str += "." + this.dsePatch
|
|
62
|
+
}
|
|
63
|
+
if (this.preReleases !== undefined) {
|
|
64
|
+
this.preReleases.forEach((preRelease) => {
|
|
65
|
+
str += "-" + preRelease
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
if (this.build) {
|
|
69
|
+
str += "+" + this.build
|
|
70
|
+
}
|
|
71
|
+
return str
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Compares this version with the provided version.
|
|
76
|
+
* @param {VersionNumber} other
|
|
77
|
+
* @return {Number} -1 if less than other, 0 if equal, 1 if greater than.
|
|
78
|
+
*/
|
|
79
|
+
compare(other) {
|
|
80
|
+
if (this.major < other.major) {
|
|
81
|
+
return -1
|
|
82
|
+
} else if (this.major > other.major) {
|
|
83
|
+
return 1
|
|
84
|
+
} else if (this.minor < other.minor) {
|
|
85
|
+
return -1
|
|
86
|
+
} else if (this.minor > other.minor) {
|
|
87
|
+
return 1
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// sanitize patch by setting to 0 if undefined.
|
|
91
|
+
const thisPatch = this.patch || 0
|
|
92
|
+
const otherPatch = other.patch || 0
|
|
93
|
+
if (thisPatch < otherPatch) {
|
|
94
|
+
return -1
|
|
95
|
+
} else if (thisPatch > otherPatch) {
|
|
96
|
+
return 1
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// if dsePatch is set in one case, but not other, consider the one where it is set as greater.
|
|
100
|
+
if (this.dsePatch === undefined) {
|
|
101
|
+
if (other.dsePatch !== undefined) {
|
|
102
|
+
return -1
|
|
103
|
+
}
|
|
104
|
+
} else if (other.dsePatch === undefined) {
|
|
105
|
+
return 1
|
|
106
|
+
} else {
|
|
107
|
+
if (this.dsePatch < other.dsePatch) {
|
|
108
|
+
return -1
|
|
109
|
+
} else if (this.dsePatch > other.dsePatch) {
|
|
110
|
+
return 1
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// If prereleases are present, consider less than those that don't have any.
|
|
115
|
+
if (this.preReleases === undefined) {
|
|
116
|
+
if (other.preReleases !== undefined) {
|
|
117
|
+
return 1
|
|
118
|
+
}
|
|
119
|
+
} else if (other.preReleases === undefined) {
|
|
120
|
+
return -1
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Don't consider build.
|
|
124
|
+
return 0
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
static parse(version) {
|
|
128
|
+
if (!version) {
|
|
129
|
+
return null
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const match = version.match(_versionPattern)
|
|
133
|
+
if (match) {
|
|
134
|
+
const major = parseInt(match[1], 10)
|
|
135
|
+
const minor = parseInt(match[2], 10)
|
|
136
|
+
const patch = match[3] ? parseInt(match[3], 10) : undefined
|
|
137
|
+
const dsePatch = match[4] ? parseInt(match[4], 10) : undefined
|
|
138
|
+
const preReleases = match[5] ? match[5].split("-") : undefined
|
|
139
|
+
const build = match[6]
|
|
140
|
+
return new VersionNumber(
|
|
141
|
+
major,
|
|
142
|
+
minor,
|
|
143
|
+
patch,
|
|
144
|
+
dsePatch,
|
|
145
|
+
preReleases,
|
|
146
|
+
build,
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
throw new TypeError("Could not extract version from '" + version + "'")
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export default VersionNumber
|