-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from codepress/develop
1.0.1
- Loading branch information
Showing
3 changed files
with
36 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,33 @@ | ||
/** | ||
* Return a pixel string -> 4px | ||
* | ||
* @param number | ||
* @returns {string} | ||
*/ | ||
export function toPixel( number ) { | ||
return number + 'px'; | ||
} | ||
|
||
/** | ||
* Javascript version of sprintf | ||
* | ||
* Usage: Format( '{0} is {1}', 'ES6', 'Awesome' ); | ||
* | ||
* @param {String} format | ||
* @returns {*} | ||
*/ | ||
export function Format( format ) { | ||
let args = Array.prototype.slice.call( arguments, 1 ); | ||
return format.replace( /{(\d+)}/g, function( match, number ) { | ||
return typeof args[ number ] !== 'undefined' | ||
? args[ number ] | ||
: match | ||
; | ||
} ); | ||
} | ||
|
||
export function isFloat( value, decimal_point_regex ) { | ||
let regex = new RegExp( "^[0-9]+((\." + decimal_point_regex + ")[0-9]+)?$" ); | ||
|
||
return value.match( regex ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters