Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function decodeZigZag64(n) {
// (n >>> 1) ^ -(n & 1);
return n.shiftRightUnsigned(1).xor(n.and(Long.ONE).negate());
}
ByteBuffer.zigZagDecode64 = function(value) {
if (typeof value === 'number')
value = Long.fromNumber(value, false);
else if (value.unsigned !== false) value = value.toSigned();
// ref: src/google/protobuf/wire_format_lite.h
return value.shiftRightUnsigned(1).xor(value.and(Long.ONE).toSigned().negate()).toSigned();
};
function computeUnsignedVIntSize(value) {
const magnitude = numberOfLeadingZeros(value.or(Long.ONE));
return (639 - magnitude * 9) >> 6;
}
Builder.prototype.addNanos = function(nanos) {
const value = typeof nanos === 'string' ? Long.fromString(nanos) : nanos;
this._validateOrder(10);
this._validateNanos(value, Long.ONE);
this._nanoseconds = this._nanoseconds.add(value);
return this;
};
}
if (this.months < 0 || this.days < 0 || this.nanoseconds.isNegative()) {
value = '-';
}
let remainder = append(Math.abs(this.months), monthsPerYear, "y");
append(remainder, 1, "mo");
append(Math.abs(this.days), 1, "d");
if (!this.nanoseconds.equals(Long.ZERO)) {
const nanos = this.nanoseconds.isNegative() ? this.nanoseconds.negate() : this.nanoseconds;
remainder = append64(nanos, nanosPerHour, "h");
remainder = append64(remainder, nanosPerMinute, "m");
remainder = append64(remainder, nanosPerSecond, "s");
remainder = append64(remainder, nanosPerMilli, "ms");
remainder = append64(remainder, nanosPerMicro, "us");
append64(remainder, Long.ONE, "ns");
}
return value;
};