version bump 1.2.2: old node shim

This commit is contained in:
SheetJS 2019-07-29 07:01:48 -04:00
parent f04791d1e7
commit e6d6f001c5
14 changed files with 43 additions and 49 deletions

View File

@ -7,14 +7,15 @@ compliance, performance and IE6+ support.
PRINTJ.sprintf("Hello %s!", "World");
```
A self-contained specification of the printf format string is included below in [this README](#printf-format-string-specification), as well as a summary of the
A self-contained specification of the printf format string is included below in
[this README](#printf-format-string-specification), as well as a summary of the
[support against various printf implementations](#support-summary)
## Table of Contents
<details>
<summary><b>Table of Contents</b> (click to show)</summary>
<summary><b>Table of Contents</b> (click to show)</summary>
<!-- toc -->
@ -163,8 +164,6 @@ granted by the Apache 2.0 license are reserved by the Original Author.
[![Dependencies Status](https://david-dm.org/sheetjs/printj/status.svg)](https://david-dm.org/sheetjs/printj)
[![ghit.me](https://ghit.me/badge.svg?repo=sheetjs/printj)](https://ghit.me/repo/sheetjs/printj)
[![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/printj?pixel)](https://github.com/SheetJS/printj)
# printf format string specification
@ -595,7 +594,7 @@ lengths exceeding 32 bits, `Math.round` is appropriate.
|------|---------------------------|-------------------------------------------|
| 8 | `V & 0xFF` | `V &= 0xFF; if(V > 0x7F) V-= 0x100` |
| 16 | `V & 0xFFFF` | `V &= 0xFFFF; if(V > 0x7FFF) V-= 0x10000` |
| 32 | `V >>> 0` | `V | 0` |
| 32 | `V >>> 0` | `V \| 0` |
| 64 | `Math.abs(Math.round(V))` | `Math.round(V)` |
## Length Specifiers for Integer Conversions
@ -900,7 +899,7 @@ In all forms other than `"%m"`, an argument will be processed as follows:
- If the `errno` field is set, emit "Error number " followed by the errno
- Otherwise emit "Error " followed by the error interpreted as a String
```
```js
var x = new Error("sheetjs");
x.errno = 69; x.toString = function() { return "SHEETJS"; };
printf("|%#m|", x); // |sheetjs|
@ -962,7 +961,7 @@ Width, precision and other flags are ignored.
Under the "T" conversion, the result of `typeof arg` is rendered. If the `#`
flag is specified, the type is derived from `Object.prototype.toString`:
```
```js
printf("%1$T %1$#T", 1); // 'number Number'
printf("%1$T %1$#T", 'foo'); // 'string String'
printf("%1$T %1$#T", [1,2,3]); // 'object Array'
@ -972,7 +971,7 @@ printf("%1$T %1$#T", undefined); // 'undefined Undefined'
Under the "V" conversion, the result of `arg.valueOf()` is rendered:
```
```js
var _f = function() { return "f"; };
var _3 = function() { return 3; };
printf("%1$d %1$s %1$V", {toString:_f}); // '0 f f'

View File

@ -3,6 +3,7 @@
/* eslint-env node */
/* vim: set ts=2 ft=javascript: */
/*jshint node:true, evil:true */
require("../shim");
var X = require("../"), argv = process.argv;
function help() {

View File

@ -1 +1 @@
PRINTJ.version = '1.2.1';
PRINTJ.version = '1.2.2';

View File

@ -25,7 +25,7 @@ var PRINTJ;
/*jshint ignore:end */
}(function(PRINTJ) {
PRINTJ.version = '1.2.1';
PRINTJ.version = '1.2.2';
function tokenize(fmt) {
var out = [];

View File

@ -3,6 +3,7 @@ var X;
var IMPLS = {}, IMPLA = [], IMPL = [];
if(typeof require !== 'undefined') {
assert = require('assert');
require('./shim');
X=require('./');
IMPL = require("./lib/impl.json");
IMPL.forEach(function(impl, i) { IMPLS[impl] = IMPLA[i] = require("./lib/" + impl); });

56
dist/printj.js vendored
View File

@ -25,7 +25,7 @@ var PRINTJ;
/*jshint ignore:end */
}(function(PRINTJ) {
PRINTJ.version = '1.1.2';
PRINTJ.version = '1.2.2';
function tokenize(fmt) {
var out = [];
@ -149,14 +149,6 @@ function tokenize(fmt) {
return out;
}
//#define PAD_(x,c) (x >= 0 ? new Array(((x)|0) + 1).join((c)) : "")
var padstr = {
" ": " ",
"0": "000000000000000000000000000000000",
"7": "777777777777777777777777777777777",
"f": "fffffffffffffffffffffffffffffffff"
};
/*global process:true, util:true, require:true */
if(typeof process !== 'undefined' && !!process.versions && !!process.versions.node) util=require("util");
var u_inspect = (typeof util != 'undefined') ? util.inspect : JSON.stringify;
@ -208,7 +200,7 @@ function doit(t, args) {
/* only valid flag is "-" for left justification */
O = String(arg);
if( prec >= 0) O = O.substr(0, prec);
if( width > O.length || - width > O.length) { if(( flags.indexOf("-") == -1 || width < 0) && flags.indexOf("0") != -1) { pad = ( width - O.length >= 0 ? padstr["0"].substr(0, width - O.length) : ""); O = pad + O; } else { pad = ( width - O.length >= 0 ? padstr[" "].substr(0, width - O.length) : ""); O = flags.indexOf("-") > -1 ? O + pad : pad + O; } }
if( width > O.length || - width > O.length) { if(( flags.indexOf("-") == -1 || width < 0) && flags.indexOf("0") != -1) { pad = ( width - O.length >= 0 ? "0".repeat( width - O.length) : ""); O = pad + O; } else { pad = ( width - O.length >= 0 ? " ".repeat( width - O.length) : ""); O = flags.indexOf("-") > -1 ? O + pad : pad + O; } }
break;
/* first char of string or convert */
@ -223,7 +215,7 @@ function doit(t, args) {
case "string": O = arg.charAt(0); break;
default: O = String(arg).charAt(0);
}
if( width > O.length || - width > O.length) { if(( flags.indexOf("-") == -1 || width < 0) && flags.indexOf("0") != -1) { pad = ( width - O.length >= 0 ? padstr["0"].substr(0, width - O.length) : ""); O = pad + O; } else { pad = ( width - O.length >= 0 ? padstr[" "].substr(0, width - O.length) : ""); O = flags.indexOf("-") > -1 ? O + pad : pad + O; } }
if( width > O.length || - width > O.length) { if(( flags.indexOf("-") == -1 || width < 0) && flags.indexOf("0") != -1) { pad = ( width - O.length >= 0 ? "0".repeat( width - O.length) : ""); O = pad + O; } else { pad = ( width - O.length >= 0 ? " ".repeat( width - O.length) : ""); O = flags.indexOf("-") > -1 ? O + pad : pad + O; } }
break;
/* int diDuUoOxXbB */
@ -308,10 +300,10 @@ function doit(t, args) {
/* boolean (extension) */
case /*Y*/ 89:
case /*y*/ 121:
O = Boolean(arg) ? (alt ? "yes" : "true") : (alt ? "no" : "false");
O = (arg) ? (alt ? "yes" : "true") : (alt ? "no" : "false");
if(c == /*Y*/ 89) O = O.toUpperCase();
if( prec >= 0) O = O.substr(0, prec);
if( width > O.length || - width > O.length) { if(( flags.indexOf("-") == -1 || width < 0) && flags.indexOf("0") != -1) { pad = ( width - O.length >= 0 ? padstr["0"].substr(0, width - O.length) : ""); O = pad + O; } else { pad = ( width - O.length >= 0 ? padstr[" "].substr(0, width - O.length) : ""); O = flags.indexOf("-") > -1 ? O + pad : pad + O; } }
if( width > O.length || - width > O.length) { if(( flags.indexOf("-") == -1 || width < 0) && flags.indexOf("0") != -1) { pad = ( width - O.length >= 0 ? "0".repeat( width - O.length) : ""); O = pad + O; } else { pad = ( width - O.length >= 0 ? " ".repeat( width - O.length) : ""); O = flags.indexOf("-") > -1 ? O + pad : pad + O; } }
break;
}
@ -373,16 +365,16 @@ function doit(t, args) {
if(radix == 16 || radix == -16) {
O = (Vnum>>>0).toString(16);
Vnum = Math.floor((Vnum - (Vnum >>> 0)) / Math.pow(2,32));
O = (Vnum>>>0).toString(16) + (8 - O.length >= 0 ? padstr[ "0"].substr(0,8 - O.length) : "") + O;
O = (16 - O.length >= 0 ? padstr[ "f"].substr(0,16 - O.length) : "") + O;
O = (Vnum>>>0).toString(16) + (8 - O.length >= 0 ? "0".repeat(8 - O.length) : "") + O;
O = (16 - O.length >= 0 ? "f".repeat(16 - O.length) : "") + O;
if(radix == 16) O = O.toUpperCase();
} else if(radix == 8) {
O = (Vnum>>>0).toString(8);
O = (10 - O.length >= 0 ? padstr[ "0"].substr(0,10 - O.length) : "") + O;
O = (10 - O.length >= 0 ? "0".repeat(10 - O.length) : "") + O;
Vnum = Math.floor((Vnum - ((Vnum >>> 0)&0x3FFFFFFF)) / Math.pow(2,30));
O = (Vnum>>>0).toString(8) + O.substr(O.length - 10);
O = O.substr(O.length - 20);
O = "1" + (21 - O.length >= 0 ? padstr[ "7"].substr(0,21 - O.length) : "") + O;
O = "1" + (21 - O.length >= 0 ? "7".repeat(21 - O.length) : "") + O;
} else {
Vnum = (-Vnum) % 1e16;
var d1 = [1,8,4,4,6,7,4,4,0,7,3,7,0,9,5,5,1,6,1,6];
@ -403,8 +395,8 @@ function doit(t, args) {
if(prec ===0 && O == "0" && !(radix == 8 && alt)) O = ""; /* bail out */
else {
if(O.length < prec + (O.substr(0,1) == "-" ? 1 : 0)) {
if(O.substr(0,1) != "-") O = (prec - O.length >= 0 ? padstr[ "0"].substr(0,prec - O.length) : "") + O;
else O = O.substr(0,1) + (prec + 1 - O.length >= 0 ? padstr[ "0"].substr(0,prec + 1 - O.length) : "") + O.substr(1);
if(O.substr(0,1) != "-") O = (prec - O.length >= 0 ? "0".repeat(prec - O.length) : "") + O;
else O = O.substr(0,1) + (prec + 1 - O.length >= 0 ? "0".repeat(prec + 1 - O.length) : "") + O.substr(1);
}
/* add prefix for # form */
@ -425,10 +417,10 @@ function doit(t, args) {
if(width > 0) {
if(O.length < width) {
if(flags.indexOf("-") > -1) {
O = O + ((width - O.length) >= 0 ? padstr[ " "].substr(0,(width - O.length)) : "");
O = O + ((width - O.length) >= 0 ? " ".repeat((width - O.length)) : "");
} else if(flags.indexOf("0") > -1 && prec < 0 && O.length > 0) {
if(prec > O.length) O = ((prec - O.length) >= 0 ? padstr[ "0"].substr(0,(prec - O.length)) : "") + O;
pad = ((width - O.length) >= 0 ? padstr[ (prec > 0 ? " " : "0")].substr(0,(width - O.length)) : "");
if(prec > O.length) O = ((prec - O.length) >= 0 ? "0".repeat((prec - O.length)) : "") + O;
pad = ((width - O.length) >= 0 ? (prec > 0 ? " " : "0").repeat((width - O.length)) : "");
if(O.charCodeAt(0) < 48) {
if(O.charAt(2).toLowerCase() == "x") O = O.substr(0,3) + pad + O.substring(3);
else O = O.substr(0,1) + pad + O.substring(1);
@ -436,7 +428,7 @@ function doit(t, args) {
else if(O.charAt(1).toLowerCase() == "x") O = O.substr(0,2) + pad + O.substring(2);
else O = pad + O;
} else {
O = ((width - O.length) >= 0 ? padstr[ " "].substr(0,(width - O.length)) : "") + O;
O = ((width - O.length) >= 0 ? " ".repeat((width - O.length)) : "") + O;
}
}
}
@ -483,8 +475,8 @@ function doit(t, args) {
O = Vnum.toExponential(20);
E = +O.substr(O.indexOf("e")+1);
O = O.charAt(0) + O.substr(2,O.indexOf("e")-2);
O = O + (E - O.length + 1 >= 0 ? padstr[ "0"].substr(0,E - O.length + 1) : "");
if(alt || (prec > 0 && isnum !== 11)) O = O + "." + (prec >= 0 ? padstr[ "0"].substr(0,prec) : "");
O = O + (E - O.length + 1 >= 0 ? "0".repeat(E - O.length + 1) : "");
if(alt || (prec > 0 && isnum !== 11)) O = O + "." + (prec >= 0 ? "0".repeat(prec) : "");
break;
/* e/E exponential */
@ -498,7 +490,7 @@ function doit(t, args) {
/* a/A hex */
case 4:
if(Vnum===0){O= "0x0"+((alt||prec>0)?"."+(prec >= 0 ? padstr["0"].substr(0,prec) : ""):"")+"p+0"; break;}
if(Vnum===0){O= "0x0"+((alt||prec>0)?"."+(prec >= 0 ? "0".repeat(prec) : ""):"")+"p+0"; break;}
O = Vnum.toString(16);
/* First char 0-9 */
var ac = O.charCodeAt(0);
@ -545,11 +537,11 @@ function doit(t, args) {
if(prec > 0) {
O = O.substr(0, prec + 2);
if(O.length < prec + 2) {
if(O.charCodeAt(0) < 48) O = O.charAt(0) + ((prec + 2 - O.length) >= 0 ? padstr[ "0"].substr(0,(prec + 2 - O.length)) : "") + O.substr(1);
else O += ((prec + 2 - O.length) >= 0 ? padstr[ "0"].substr(0,(prec + 2 - O.length)) : "");
if(O.charCodeAt(0) < 48) O = O.charAt(0) + ((prec + 2 - O.length) >= 0 ? "0".repeat((prec + 2 - O.length)) : "") + O.substr(1);
else O += ((prec + 2 - O.length) >= 0 ? "0".repeat((prec + 2 - O.length)) : "");
}
} else if(prec === 0) O = O.charAt(0) + (alt ? "." : "");
} else if(prec > 0) O = O + "." + (prec >= 0 ? padstr["0"].substr(0,prec) : "");
} else if(prec > 0) O = O + "." + (prec >= 0 ? "0".repeat(prec) : "");
else if(alt) O = O + ".";
O = "0x" + O + "p" + (E>=0 ? "+" + E : E);
break;
@ -566,9 +558,9 @@ function doit(t, args) {
/* width */
if(width > O.length) {
if(flags.indexOf("-") > -1) {
O = O + ((width - O.length) >= 0 ? padstr[ " "].substr(0,(width - O.length)) : "");
O = O + ((width - O.length) >= 0 ? " ".repeat((width - O.length)) : "");
} else if(flags.indexOf("0") > -1 && O.length > 0 && isf) {
pad = ((width - O.length) >= 0 ? padstr[ "0"].substr(0,(width - O.length)) : "");
pad = ((width - O.length) >= 0 ? "0".repeat((width - O.length)) : "");
if(O.charCodeAt(0) < 48) {
if(O.charAt(2).toLowerCase() == "x") O = O.substr(0,3) + pad + O.substring(3);
else O = O.substr(0,1) + pad + O.substring(1);
@ -576,7 +568,7 @@ function doit(t, args) {
else if(O.charAt(1).toLowerCase() == "x") O = O.substr(0,2) + pad + O.substring(2);
else O = pad + O;
} else {
O = ((width - O.length) >= 0 ? padstr[ " "].substr(0,(width - O.length)) : "") + O;
O = ((width - O.length) >= 0 ? " ".repeat((width - O.length)) : "") + O;
}
}
if(c < 96) O = O.toUpperCase();

2
dist/printj.min.js vendored

File diff suppressed because one or more lines are too long

2
dist/printj.min.map vendored

File diff suppressed because one or more lines are too long

View File

@ -7,7 +7,7 @@
var PRINTJ/*:PRINTJModule*/ = /*::(*/{}/*:: :any)*/;
PRINTJ.version = '1.2.1';
PRINTJ.version = '1.2.2';
export const version = PRINTJ.version;

View File

@ -1,6 +1,6 @@
{
"name": "printj",
"version": "1.2.1",
"version": "1.2.2",
"author": "sheetjs",
"description": "Pure-JS printf",
"keywords": [

View File

@ -28,7 +28,7 @@ var PRINTJ/*:PRINTJModule*/;
/*jshint ignore:end */
}(function(PRINTJ/*:PRINTJModule*/) {
PRINTJ.version = '1.2.1';
PRINTJ.version = '1.2.2';
function tokenize(fmt/*:string*/)/*:ParsedFmt*/ {
var out/*:ParsedFmt*/ = [];

View File

@ -25,7 +25,7 @@ var PRINTJ;
/*jshint ignore:end */
}(function(PRINTJ) {
PRINTJ.version = '1.2.1';
PRINTJ.version = '1.2.2';
function tokenize(fmt) {
var out = [];

View File

@ -7,7 +7,7 @@
var PRINTJ/*:PRINTJModule*/ = /*::(*/{}/*:: :any)*/;
PRINTJ.version = '1.2.1';
PRINTJ.version = '1.2.2';
export const version = PRINTJ.version;

View File

@ -3,6 +3,7 @@ var X;
var IMPLS = {}, IMPLA = [], IMPL = [];
if(typeof require !== 'undefined') {
assert = require('assert');
require('./shim');
X=require('./');
IMPL = require("./lib/impl.json");
IMPL.forEach(function(impl, i) { IMPLS[impl] = IMPLA[i] = require("./lib/" + impl); });