input-format
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -68,3 +68,3 @@ 'use strict'; | ||
while (index < text.length) { | ||
while (index < text.length && index < template.length) { | ||
// Character placeholder found | ||
@@ -71,0 +71,0 @@ if (text[index] !== template[index]) { |
@@ -15,2 +15,6 @@ 'use strict'; | ||
var _closeBraces = require('./close braces'); | ||
var _closeBraces2 = _interopRequireDefault(_closeBraces); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -26,4 +30,9 @@ | ||
// | ||
// If `should_close_braces` is `true`, | ||
// then it will also make sure all dangling braces are closed, | ||
// e.g. "8 (8" -> "8 (8 )" (iPhone style phone number input). | ||
// | ||
function template_formatter(template) { | ||
var placeholder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'x'; | ||
var should_close_braces = arguments[2]; | ||
@@ -90,2 +99,6 @@ if (!template) { | ||
if (should_close_braces) { | ||
filled_in_template = (0, _closeBraces2.default)(filled_in_template, template); | ||
} | ||
return { text: filled_in_template, template: template }; | ||
@@ -92,0 +105,0 @@ }; |
{ | ||
"name": "input-format", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Formatting user's text input on-the-fly", | ||
@@ -5,0 +5,0 @@ "main": "index.common.js", |
@@ -62,3 +62,3 @@ import template_formatter from './template formatter' | ||
while (index < text.length) | ||
while (index < text.length && index < template.length) | ||
{ | ||
@@ -65,0 +65,0 @@ // Character placeholder found |
import { count_occurences } from './helpers' | ||
import close_braces from './close braces' | ||
@@ -11,3 +12,7 @@ // Takes a `template` where character placeholders | ||
// | ||
export default function template_formatter(template, placeholder = 'x') | ||
// If `should_close_braces` is `true`, | ||
// then it will also make sure all dangling braces are closed, | ||
// e.g. "8 (8" -> "8 (8 )" (iPhone style phone number input). | ||
// | ||
export default function template_formatter(template, placeholder = 'x', should_close_braces) | ||
{ | ||
@@ -58,4 +63,9 @@ if (!template) | ||
if (should_close_braces) | ||
{ | ||
filled_in_template = close_braces(filled_in_template, template) | ||
} | ||
return { text: filled_in_template, template } | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71147
41
1192