Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "JsiUtils.h"
 
using namespace facebook::jsi;
 
bool isTypedArray(Runtime& runtime, const Object& jsObj) {
  if (!jsObj.hasProperty(runtime, "buffer"))
    return false;
  if (!jsObj.getProperty(runtime, "buffer")
           .asObject(runtime)
           .isArrayBuffer(runtime))
    return false;
  return true;
}
 
void forEach(Runtime& runtime, const Object& object,
             const std::function<void(const std::string&, const Value&,
                                      size_t)>& callback) {
  auto names = object.getPropertyNames(runtime);
  for (size_t i = 0; i < names.size(runtime); i++) {
    auto key =
        names.getValueAtIndex(runtime, i).asString(runtime).utf8(runtime);
    auto value = object.getProperty(runtime, key.c_str());
    callback(key, value, i);
  }
}
 
void forEach(Runtime& runtime, const Array& array,
             const std::function<void(const Value&, size_t)>& callback) {
  for (size_t i = 0; i < array.size(runtime); i++) {
    callback(array.getValueAtIndex(runtime, i), i);
  }
}