From 560d2c7b70f099829034191fa324ffa79e9836d8 Mon Sep 17 00:00:00 2001 From: joaquinelio Date: Wed, 15 Jul 2020 19:24:06 -0300 Subject: [PATCH 01/11] 1-99-5 bigint 1ra version --- 1-js/99-js-misc/05-bigint/article.md | 84 ++++++++++++++-------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/1-js/99-js-misc/05-bigint/article.md b/1-js/99-js-misc/05-bigint/article.md index 72f06d0c7..7c9097863 100644 --- a/1-js/99-js-misc/05-bigint/article.md +++ b/1-js/99-js-misc/05-bigint/article.md @@ -2,21 +2,21 @@ [recent caniuse="bigint"] -`BigInt` is a special numeric type that provides support for integers of arbitrary length. +`BigInt` es un tipo numérico especial que provee soporte a enteros de largo arbitrario. -A bigint is created by appending `n` to the end of an integer literal or by calling the function `BigInt` that creates bigints from strings, numbers etc. +Un bigint se crea agregando `n` al final del literal entero o llamando a la función `BigInt` que crea bigints desde cadenas, números, etc. ```js const bigint = 1234567890123456789012345678901234567890n; const sameBigint = BigInt("1234567890123456789012345678901234567890"); -const bigintFromNumber = BigInt(10); // same as 10n +const bigintFromNumber = BigInt(10); // lo mismo que 10n ``` -## Math operators +## Operadores matemáticos -`BigInt` can mostly be used like a regular number, for example: +`BigInt` puede ser usado mayormente como un número regular, por ejemplo: ```js run alert(1n + 2n); // 3 @@ -24,44 +24,44 @@ alert(1n + 2n); // 3 alert(5n / 2n); // 2 ``` -Please note: the division `5/2` returns the result rounded towards zero, without the decimal part. All operations on bigints return bigints. +Por favor ten en cuenta: la división `5/2` devuelve el resultado redondeado a cero, sin la parte decimal. Todas las operaciones sobre bigints devuelven bigints. -We can't mix bigints and regular numbers: +No podemos mezclar bigints con números regularess: ```js run -alert(1n + 2); // Error: Cannot mix BigInt and other types +alert(1n + 2); // Error: No se puede mezclar BigInt y otros tipos. ``` -We should explicitly convert them if needed: using either `BigInt()` or `Number()`, like this: +Podemos convertirlos explícitamente cuando es necesario: usando `BigInt()` o `Number()` como aquí: ```js run let bigint = 1n; let number = 2; -// number to bigint +// De number a bigint alert(bigint + BigInt(number)); // 3 -// bigint to number +// De bigint a number alert(Number(bigint) + number); // 3 ``` -The conversion operations are always silent, never give errors, but if the bigint is too huge and won't fit the number type, then extra bits will be cut off, so we should be careful doing such conversion. +Las operaciones de conversión siempre son silenciosas, nunca dan error, pero si el bigint es tan gigante que no podrá ajustarse al tipo numérico, los bits extra serán recortados, entonces deberíamos ser cuidadosos en hacer tal conversión. -````smart header="The unary plus is not supported on bigints" -The unary plus operator `+value` is a well-known way to convert `value` to a number. +````smart header="El unario más no tiene soporte en bigints" +El operador unario más `+value` es una manera bien conocida de convertir `value` a number. -On bigints it's not supported, to avoid confusion: +Con bigints eso no es soportado para evitar confusión: ```js run let bigint = 1n; alert( +bigint ); // error ``` -So we should use `Number()` to convert a bigint to a number. +Entonces debemos usar `Number()` para convertir un bigint a number. ```` -## Comparisons +## Comparaciones -Comparisons, such as `<`, `>` work with bigints and numbers just fine: +Comparaciones tales como `<`, `>` funcionan bien entre bigints y numbers: ```js run alert( 2n > 1n ); // true @@ -69,7 +69,7 @@ alert( 2n > 1n ); // true alert( 2n > 1 ); // true ``` -Please note though, as numbers and bigints belong to different types, they can be equal `==`, but not strictly equal `===`: +Aunque por favor, nota que number y bigint pertenecen a difierntes tipos, ellos pueden ser iguales `==`, pero no estrictamente iguales `===`: ```js run alert( 1 == 1n ); // true @@ -77,54 +77,54 @@ alert( 1 == 1n ); // true alert( 1 === 1n ); // false ``` -## Boolean operations +## Operaciones booleanas -When inside `if` or other boolean operations, bigints behave like numbers. +Cuando estan dentro de un `if` u otra operación booleana, los bigints se comportan como numbers. -For instance, in `if`, bigint `0n` is falsy, other values are truthy: +Por ejemplo, en `if`, el bigint `0n` is falso, los otros valores son verdaderos: ```js run if (0n) { - // never executes + // nunca se ejecuta } ``` -Boolean operators, such as `||`, `&&` and others also work with bigints similar to numbers: +Los operadoress booleanos como `||`, `&&` y otros también trabajan con bigints en forma similar a los number: ```js run -alert( 1n || 2 ); // 1 (1n is considered truthy) +alert( 1n || 2 ); // 1 (1n es considerado verdadero) -alert( 0n || 2 ); // 2 (0n is considered falsy) +alert( 0n || 2 ); // 2 (0n es considerado falso) ``` ## Polyfills -Polyfilling bigints is tricky. The reason is that many JavaScript operators, such as `+`, `-` and so on behave differently with bigints compared to regular numbers. +Hacer Polyfill con bigints es trabajoso. La razón es que muchos operadores JavaScript como `+`, `-` y otros se comportan de diferente manera comparados con los números regulares. -For example, division of bigints always returns a bigint (rounded if necessary). +Por ejemplo, la división de bigints siempre devuelve un bigint (redondeado cuando es necesario). -To emulate such behavior, a polyfill would need to analyze the code and replace all such operators with its functions. But doing so is cumbersome and would cost a lot of performance. +Para emular tal comportamiento, un polyfill necesitaría analizar el código y reemplazar todos los operadores con sus funciones. Pero hacerlo es engorroso y tendría mucho costo en performance. -So, there's no well-known good polyfill. +Entonces no se conoce un buen polyfill. -Although, the other way around is proposed by the developers of [JSBI](https://github.com/GoogleChromeLabs/jsbi) library. +Aunque hay otra manera, la propuesta por los desarrolladores de la librería [JSBI](https://github.com/GoogleChromeLabs/jsbi). -This library implements big numbers using its own methods. We can use them instead of native bigints: +Esta librería implementa bigint usando sus propios métodos. Podemos usarlos en lugar de bigints nativos: -| Operation | native `BigInt` | JSBI | +| Operación | `BigInt` nativo | JSBI | |-----------|-----------------|------| -| Creation from Number | `a = BigInt(789)` | `a = JSBI.BigInt(789)` | -| Addition | `c = a + b` | `c = JSBI.add(a, b)` | -| Subtraction | `c = a - b` | `c = JSBI.subtract(a, b)` | +| Creación desde Number | `a = BigInt(789)` | `a = JSBI.BigInt(789)` | +| Suma | `c = a + b` | `c = JSBI.add(a, b)` | +| Resta | `c = a - b` | `c = JSBI.subtract(a, b)` | | ... | ... | ... | -...And then use the polyfill (Babel plugin) to convert JSBI calls to native bigints for those browsers that support them. +...Y entonces usar polyfill (plugin Babel) para convertir las llamadas de JSBI en bigints nativos para aquellos navegadores que los soporten. -In other words, this approach suggests that we write code in JSBI instead of native bigints. But JSBI works with numbers as with bigints internally, emulates them closely following the specification, so the code will be "bigint-ready". +En otras palabras, este enfoque sugiere que escribamos código en JSBI en lugar de bigints nativos. Pero JSBI trabaja internamente tanto con numbers como con bigints, los emula siguiendo de cerca la especificación, entonces el código será "bigint-ready" preparado para bigint. -We can use such JSBI code "as is" for engines that don't support bigints and for those that do support - the polyfill will convert the calls to native bigints. +Podemos usar tal código JSBI "tal como está" en motores que no soportan bigints, y para aquellos que sí lo soportan - el polyfill convertirá las llamadas en bigints nativos. -## References +## Referencias -- [MDN docs on BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt). -- [Specification](https://tc39.es/ecma262/#sec-bigint-objects). +- [MDN documentación BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt). +- [Especificación](https://tc39.es/ecma262/#sec-bigint-objects). From 005670507cc2bf126e7ec66d79dcd84d15fff368 Mon Sep 17 00:00:00 2001 From: joaquinelio Date: Thu, 16 Jul 2020 08:48:50 -0300 Subject: [PATCH 02/11] Update 1-js/99-js-misc/05-bigint/article.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pffff Mandale un PR al repo inglés entonces, acá qué tengo que ver. ja! me pareció... y despues no lo crei muy importante, pereza. Sigue siendo incómodo, con la correcta aclaración arbitraria está mas ociosa todavia... Ahora commit porque aclara, pero despues busco algo mejor, y si encontramos algo perfecto: PR a Ilya. "arbitrario" porque los otro sson algo "limitados", pero no esta bien expresado. Co-authored-by: Maksumi Murakami --- 1-js/99-js-misc/05-bigint/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/99-js-misc/05-bigint/article.md b/1-js/99-js-misc/05-bigint/article.md index 7c9097863..14a559fa3 100644 --- a/1-js/99-js-misc/05-bigint/article.md +++ b/1-js/99-js-misc/05-bigint/article.md @@ -2,7 +2,7 @@ [recent caniuse="bigint"] -`BigInt` es un tipo numérico especial que provee soporte a enteros de largo arbitrario. +`BigInt` es un tipo numérico especial que provee soporte a enteros de longitud arbitraria (muy grandes). Un bigint se crea agregando `n` al final del literal entero o llamando a la función `BigInt` que crea bigints desde cadenas, números, etc. From 0ead30076ca6605b6faf965bc1119b24e55e61dd Mon Sep 17 00:00:00 2001 From: joaquinelio Date: Thu, 16 Jul 2020 08:57:03 -0300 Subject: [PATCH 03/11] Update 1-js/99-js-misc/05-bigint/article.md Co-authored-by: Maksumi Murakami --- 1-js/99-js-misc/05-bigint/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/99-js-misc/05-bigint/article.md b/1-js/99-js-misc/05-bigint/article.md index 14a559fa3..c2daecf35 100644 --- a/1-js/99-js-misc/05-bigint/article.md +++ b/1-js/99-js-misc/05-bigint/article.md @@ -26,7 +26,7 @@ alert(5n / 2n); // 2 Por favor ten en cuenta: la división `5/2` devuelve el resultado redondeado a cero, sin la parte decimal. Todas las operaciones sobre bigints devuelven bigints. -No podemos mezclar bigints con números regularess: +No podemos mezclar bigints con números regulares: ```js run alert(1n + 2); // Error: No se puede mezclar BigInt y otros tipos. From 723e6193963b29c94c9e8013f481ae25533bfedc Mon Sep 17 00:00:00 2001 From: joaquinelio Date: Thu, 16 Jul 2020 09:01:48 -0300 Subject: [PATCH 04/11] Update 1-js/99-js-misc/05-bigint/article.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ¿no escribi esto ya? Peleo con el exceso de comas pero aca está bien la correccion. Ahora veo mal el exceso de "por favor" que en ingles no distrae tanto. "por favor nota" es horrible "ten en cuenta" Por qué "por favor" too needy despues lo saco, opina please. Co-authored-by: Maksumi Murakami --- 1-js/99-js-misc/05-bigint/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/99-js-misc/05-bigint/article.md b/1-js/99-js-misc/05-bigint/article.md index c2daecf35..e042dd8be 100644 --- a/1-js/99-js-misc/05-bigint/article.md +++ b/1-js/99-js-misc/05-bigint/article.md @@ -24,7 +24,7 @@ alert(1n + 2n); // 3 alert(5n / 2n); // 2 ``` -Por favor ten en cuenta: la división `5/2` devuelve el resultado redondeado a cero, sin la parte decimal. Todas las operaciones sobre bigints devuelven bigints. +Por favor, ten en cuenta: la división `5/2` devuelve el resultado redondeado a cero, sin la parte decimal. Todas las operaciones sobre bigints devuelven bigints. No podemos mezclar bigints con números regulares: From c2907cc9e23ac9ee3f80bac62b4e7c53b7c8042a Mon Sep 17 00:00:00 2001 From: joaquinelio Date: Thu, 16 Jul 2020 09:26:15 -0300 Subject: [PATCH 05/11] Update 1-js/99-js-misc/05-bigint/article.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... no... ...no del todo. Buena defectuosa correccion (difierentes) y sí falta una buena conexion pero cambiare "aunque". ... y cada vez más me molesta el "por favor" ¿que opinas? Lo hace para que prestess más atencion, pero en español creo que distrae Co-authored-by: Maksumi Murakami --- 1-js/99-js-misc/05-bigint/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/99-js-misc/05-bigint/article.md b/1-js/99-js-misc/05-bigint/article.md index e042dd8be..3d0e984d5 100644 --- a/1-js/99-js-misc/05-bigint/article.md +++ b/1-js/99-js-misc/05-bigint/article.md @@ -69,7 +69,7 @@ alert( 2n > 1n ); // true alert( 2n > 1 ); // true ``` -Aunque por favor, nota que number y bigint pertenecen a difierntes tipos, ellos pueden ser iguales `==`, pero no estrictamente iguales `===`: +Por favor, nota que aunque number y bigint pertenecen a difierentes tipos, ellos pueden ser iguales `==`, pero no estrictamente iguales `===`: ```js run alert( 1 == 1n ); // true From 30d4ad330516ff668a46afaed3cf8611cbe15fd5 Mon Sep 17 00:00:00 2001 From: joaquinelio Date: Thu, 16 Jul 2020 09:26:45 -0300 Subject: [PATCH 06/11] Update 1-js/99-js-misc/05-bigint/article.md Co-authored-by: Maksumi Murakami --- 1-js/99-js-misc/05-bigint/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/99-js-misc/05-bigint/article.md b/1-js/99-js-misc/05-bigint/article.md index 3d0e984d5..63ed2e4de 100644 --- a/1-js/99-js-misc/05-bigint/article.md +++ b/1-js/99-js-misc/05-bigint/article.md @@ -81,7 +81,7 @@ alert( 1 === 1n ); // false Cuando estan dentro de un `if` u otra operación booleana, los bigints se comportan como numbers. -Por ejemplo, en `if`, el bigint `0n` is falso, los otros valores son verdaderos: +Por ejemplo, en `if`, el bigint `0n` es falso, los otros valores son verdaderos: ```js run if (0n) { From 93c9914773fdfe177b15de285d1fcd34a8d304b5 Mon Sep 17 00:00:00 2001 From: joaquinelio Date: Thu, 16 Jul 2020 09:27:48 -0300 Subject: [PATCH 07/11] Update 1-js/99-js-misc/05-bigint/article.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ¡PERFECTO! no me gustaba. Demasiados entonces. "so" es tan práctico... Co-authored-by: Maksumi Murakami --- 1-js/99-js-misc/05-bigint/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/99-js-misc/05-bigint/article.md b/1-js/99-js-misc/05-bigint/article.md index 63ed2e4de..7e4f007d9 100644 --- a/1-js/99-js-misc/05-bigint/article.md +++ b/1-js/99-js-misc/05-bigint/article.md @@ -105,7 +105,7 @@ Por ejemplo, la división de bigints siempre devuelve un bigint (redondeado cuan Para emular tal comportamiento, un polyfill necesitaría analizar el código y reemplazar todos los operadores con sus funciones. Pero hacerlo es engorroso y tendría mucho costo en performance. -Entonces no se conoce un buen polyfill. +Por lo que no se conoce un buen polyfill. Aunque hay otra manera, la propuesta por los desarrolladores de la librería [JSBI](https://github.com/GoogleChromeLabs/jsbi). From 708ffc9be1534c52a863b30e13787bcb08b55278 Mon Sep 17 00:00:00 2001 From: joaquinelio Date: Thu, 16 Jul 2020 09:35:24 -0300 Subject: [PATCH 08/11] Update 1-js/99-js-misc/05-bigint/article.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mm... quizás facilite la lectura, pero: Peleo contra el exceso de comas, pero estas sesparan elementos si forzas una, hay que agregar otra, el test es quitar el complemento entre comas y ver que la frase tenga sentido: Los op bool, tales como balabalabla, también trabajan. Los op bool también trabajan. Aplico porque mejora pero despues edito , , Co-authored-by: Maksumi Murakami --- 1-js/99-js-misc/05-bigint/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/99-js-misc/05-bigint/article.md b/1-js/99-js-misc/05-bigint/article.md index 7e4f007d9..66f2b2b94 100644 --- a/1-js/99-js-misc/05-bigint/article.md +++ b/1-js/99-js-misc/05-bigint/article.md @@ -89,7 +89,7 @@ if (0n) { } ``` -Los operadoress booleanos como `||`, `&&` y otros también trabajan con bigints en forma similar a los number: +Los operadores booleanos, tales como `||`, `&&` y otros también trabajan con bigints en forma similar a los number: ```js run alert( 1n || 2 ); // 1 (1n es considerado verdadero) From 2380c91ad8b50e56c24f9d2b7ea52b37991d893d Mon Sep 17 00:00:00 2001 From: joaquinelio Date: Thu, 16 Jul 2020 09:36:00 -0300 Subject: [PATCH 09/11] Update 1-js/99-js-misc/05-bigint/article.md Co-authored-by: Maksumi Murakami --- 1-js/99-js-misc/05-bigint/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/99-js-misc/05-bigint/article.md b/1-js/99-js-misc/05-bigint/article.md index 66f2b2b94..c9092ed7a 100644 --- a/1-js/99-js-misc/05-bigint/article.md +++ b/1-js/99-js-misc/05-bigint/article.md @@ -120,7 +120,7 @@ Esta librería implementa bigint usando sus propios métodos. Podemos usarlos en ...Y entonces usar polyfill (plugin Babel) para convertir las llamadas de JSBI en bigints nativos para aquellos navegadores que los soporten. -En otras palabras, este enfoque sugiere que escribamos código en JSBI en lugar de bigints nativos. Pero JSBI trabaja internamente tanto con numbers como con bigints, los emula siguiendo de cerca la especificación, entonces el código será "bigint-ready" preparado para bigint. +En otras palabras, este enfoque sugiere que escribamos código en JSBI en lugar de bigints nativos. Pero JSBI trabaja internamente tanto con numbers como con bigints, los emula siguiendo de cerca la especificación, entonces el código será "bigint-ready" (preparado para bigint). Podemos usar tal código JSBI "tal como está" en motores que no soportan bigints, y para aquellos que sí lo soportan - el polyfill convertirá las llamadas en bigints nativos. From 0516d8c25924cf4facdc1e87785ed9bf6575c8a0 Mon Sep 17 00:00:00 2001 From: joaquinelio Date: Thu, 16 Jul 2020 09:43:27 -0300 Subject: [PATCH 10/11] Update 1-js/99-js-misc/05-bigint/article.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ah... en hacerla, porque quizás deberiamos evitarla. o al hacerla, porque la hacemos igual pero debemos ser cuidadosos Ok. Co-authored-by: Maksumi Murakami --- 1-js/99-js-misc/05-bigint/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/99-js-misc/05-bigint/article.md b/1-js/99-js-misc/05-bigint/article.md index c9092ed7a..5407e472e 100644 --- a/1-js/99-js-misc/05-bigint/article.md +++ b/1-js/99-js-misc/05-bigint/article.md @@ -45,7 +45,7 @@ alert(bigint + BigInt(number)); // 3 alert(Number(bigint) + number); // 3 ``` -Las operaciones de conversión siempre son silenciosas, nunca dan error, pero si el bigint es tan gigante que no podrá ajustarse al tipo numérico, los bits extra serán recortados, entonces deberíamos ser cuidadosos en hacer tal conversión. +Las operaciones de conversión siempre son silenciosas, nunca dan error, pero si el bigint es tan gigante que no podrá ajustarse al tipo numérico, los bits extra serán recortados, entonces deberíamos ser cuidadosos al hacer tal conversión. ````smart header="El unario más no tiene soporte en bigints" El operador unario más `+value` es una manera bien conocida de convertir `value` a number. From 45e7b199596773180a309b9d1aa8907187c37dfc Mon Sep 17 00:00:00 2001 From: joaquinelio Date: Thu, 16 Jul 2020 10:27:27 -0300 Subject: [PATCH 11/11] Update article.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @ eh! @ ¿como loss menciono=? no anda article 5 27 53 72 92 --- 1-js/99-js-misc/05-bigint/article.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/1-js/99-js-misc/05-bigint/article.md b/1-js/99-js-misc/05-bigint/article.md index 5407e472e..d9baed0a3 100644 --- a/1-js/99-js-misc/05-bigint/article.md +++ b/1-js/99-js-misc/05-bigint/article.md @@ -2,7 +2,7 @@ [recent caniuse="bigint"] -`BigInt` es un tipo numérico especial que provee soporte a enteros de longitud arbitraria (muy grandes). +`BigInt` es un tipo numérico especial que provee soporte a enteros de tamaño arbitrario. Un bigint se crea agregando `n` al final del literal entero o llamando a la función `BigInt` que crea bigints desde cadenas, números, etc. @@ -50,7 +50,7 @@ Las operaciones de conversión siempre son silenciosas, nunca dan error, pero si ````smart header="El unario más no tiene soporte en bigints" El operador unario más `+value` es una manera bien conocida de convertir `value` a number. -Con bigints eso no es soportado para evitar confusión: +Para evitar las confusiones, con bigints eso no es soportado: ```js run let bigint = 1n; @@ -69,7 +69,7 @@ alert( 2n > 1n ); // true alert( 2n > 1 ); // true ``` -Por favor, nota que aunque number y bigint pertenecen a difierentes tipos, ellos pueden ser iguales `==`, pero no estrictamente iguales `===`: +Por favor, nota que como number y bigint pertenecen a diferentes tipos, ellos pueden ser iguales `==`, pero no estrictamente iguales `===`: ```js run alert( 1 == 1n ); // true @@ -89,7 +89,7 @@ if (0n) { } ``` -Los operadores booleanos, tales como `||`, `&&` y otros también trabajan con bigints en forma similar a los number: +Los operadores booleanos, tales como `||`, `&&` y otros, también trabajan con bigints en forma similar a los number: ```js run alert( 1n || 2 ); // 1 (1n es considerado verdadero)