|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
461 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var floor = require('./floor');
|
|---|
| 4 |
|
|---|
| 5 | var $TypeError = require('es-errors/type');
|
|---|
| 6 |
|
|---|
| 7 | // https://262.ecma-international.org/14.0/#eqn-truncate
|
|---|
| 8 |
|
|---|
| 9 | module.exports = function truncate(x) {
|
|---|
| 10 | if (typeof x !== 'number' && typeof x !== 'bigint') {
|
|---|
| 11 | throw new $TypeError('argument must be a Number or a BigInt');
|
|---|
| 12 | }
|
|---|
| 13 | var result = x < 0 ? -floor(-x) : floor(x);
|
|---|
| 14 | return result === 0 ? 0 : result; // in the spec, these are math values, so we filter out -0 here
|
|---|
| 15 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.