1
0
Fork 0
mirror of https://github.com/shimataro/ssh-key-action.git synced 2025-06-19 22:52:10 +10:00

* first action! (#1)

This commit is contained in:
shimataro 2019-09-18 20:39:54 +09:00 committed by GitHub
parent 8deacc95b1
commit ace1e6a69a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3750 changed files with 1155519 additions and 0 deletions

68
node_modules/cint/experimental/rjformat.js generated vendored Normal file
View file

@ -0,0 +1,68 @@
var RJFormat = (function() {
/*********************
* PRIVATE
*********************/
/** The string to use if the raw value is not valid. */
var invalidValueStandin = "--";
/** Returns true if the given value is not null or undefined. */
var isValue = function(val) {
return val !== undefined && val !== null;
};
/** Generates a function that calls a formatter function if the given value is valid, otherwise returns the invalidValueStandin. */
var validOr = function(f) {
return function(val) {
return isValue(val) ? f(val) : invalidValueStandin;
};
};
/*********************
* PUBLIC
*********************/
/** Mark thousands with commas. 4000000 -> 4,000,000. */
var commatize = function(val) {
var valString = val.toString();
var output = [];
for(var i=valString.length-1; i>=0; i--) {
var fromRight = valString.length - i - 1;
if(fromRight !== 0 && fromRight%3 === 0) {
output.unshift(",");
}
output.unshift(valString[i]);
}
return output.join("");
};
/** Formats the given value as a percentage. Returns the invalidValueStandin if the given raw value is null or undefined. */
var percentage = validOr(function(val) {
return val * 100 + "%";
});
var currency = validOr(function(val) {
var valString = val.toString();
var decimelLoc = valString.indexOf(".");
var decimelPlaces = decimelLoc === -1 ? 0 :
valString.length - valString.indexOf(".") - 1;
var mixed = valString.split(".");
var whole = mixed[0];
var fraction = mixed.length > 1 ? mixed[1].substring(0,2) : "";
return "${0}.{1}".supplant(
commatize(whole),
fraction + "0".repeat(2 - fraction.length)
);
});
// public interface
return {
commatize: commatize,
currency: currency,
percentage: percentage
};
})();