@react-native-firebase/app
Version:
A well tested, feature rich Firebase implementation for React Native, supporting iOS & Android. Individual module support for Admob, Analytics, Auth, Crash Reporting, Cloud Firestore, Database, Dynamic Links, Functions, Messaging (FCM), Remote Config, Sto
25 lines (23 loc) • 632 B
JavaScript
;
import { ConstraintError } from './errors.js';
const MAX_KEY = 9007199254740992;
class KeyGenerator {
// This is kind of wrong. Should start at 1 and increment only after record is saved
num = 0;
next() {
if (this.num >= MAX_KEY) {
throw new ConstraintError();
}
this.num += 1;
return this.num;
}
// https://w3c.github.io/IndexedDB/#possibly-update-the-key-generator
setIfLarger(num) {
const value = Math.floor(Math.min(num, MAX_KEY)) - 1;
if (value >= this.num) {
this.num = value + 1;
}
}
}
export default KeyGenerator;
//# sourceMappingURL=KeyGenerator.js.map