fs: add Deno.utime/Deno.utimeSync (#2241)

This commit is contained in:
Kevin (Kun) "Kassimo" Qian 2019-05-01 02:08:12 -07:00 committed by Ryan Dahl
parent c36b5dd01c
commit 7237e9d34a
12 changed files with 322 additions and 1 deletions

View file

@ -192,3 +192,18 @@ export function hasOwnProperty<T>(obj: T, v: PropertyKey): boolean {
}
return Object.prototype.hasOwnProperty.call(obj, v);
}
/**
* Split a number into two parts: lower 32 bit and higher 32 bit
* (as if the number is represented as uint64.)
*
* @param n Number to split.
* @internal
*/
export function splitNumberToParts(n: number): number[] {
// JS bitwise operators (OR, SHIFT) operate as if number is uint32.
const lower = n | 0;
// This is also faster than Math.floor(n / 0x100000000) in V8.
const higher = (n - lower) / 0x100000000;
return [lower, higher];
}