mirror of
https://github.com/denoland/deno.git
synced 2025-10-03 15:44:36 +00:00
fs: add Deno.utime/Deno.utimeSync (#2241)
This commit is contained in:
parent
c36b5dd01c
commit
7237e9d34a
12 changed files with 322 additions and 1 deletions
15
js/util.ts
15
js/util.ts
|
@ -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];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue