Skip to content

Commit

Permalink
feat: for simplicity represent flags as string
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
Parse exposes `flags` now as string and not array, so e.g. `["+", " "]`
is now exposed as "+ "
  • Loading branch information
medikoo committed Oct 2, 2018
1 parent d70a86a commit 299ffa3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion parse.js
Expand Up @@ -72,7 +72,7 @@ var states = {
if (hasOwnProperty.call(flagChars, char)) {
++index;
} else {
placeholder.flags = aFrom(formatString.slice(currentTokenStart, index));
placeholder.flags = formatString.slice(currentTokenStart, index);
state = "widthStart";
}
},
Expand Down
10 changes: 5 additions & 5 deletions test/parse.js
Expand Up @@ -143,7 +143,7 @@ test("parse", function (t) {
parse("foo %+d"),
{
literals: ["foo ", ""],
placeholders: [{ flags: ["+"], type: "d", content: "%+d" }],
placeholders: [{ flags: "+", type: "d", content: "%+d" }],
isParameterIndexingValid: true
},
"Single flag in placeholder"
Expand All @@ -153,7 +153,7 @@ test("parse", function (t) {
parse("foo %0d"),
{
literals: ["foo ", ""],
placeholders: [{ flags: ["0"], type: "d", content: "%0d" }],
placeholders: [{ flags: "0", type: "d", content: "%0d" }],
isParameterIndexingValid: true
},
"Single 0 flag in placeholder"
Expand All @@ -163,7 +163,7 @@ test("parse", function (t) {
parse("foo %0+d"),
{
literals: ["foo ", ""],
placeholders: [{ flags: ["0", "+"], type: "d", content: "%0+d" }],
placeholders: [{ flags: "0+", type: "d", content: "%0+d" }],
isParameterIndexingValid: true
},
"Multiple flags in placeholder"
Expand Down Expand Up @@ -258,7 +258,7 @@ test("parse", function (t) {
placeholders: [
{
parameter: 23,
flags: ["+", " "],
flags: "+ ",
width: 30,
precision: 30,
length: "hh",
Expand All @@ -278,7 +278,7 @@ test("parse", function (t) {
placeholders: [
{
parameter: 1,
flags: [" "],
flags: " ",
width: 3,
precision: 3,
length: "h",
Expand Down

0 comments on commit 299ffa3

Please sign in to comment.