m-util

0.0.11 • Public • Published

m-util

npm total download npm version License

インストール - Install

$ npm i -S m-util

使い方 - Usage

Functions

    // ヒアドキュメント用
    String.prototype.uHereDoc = function() {…}
--
    // スラッシュ挿入
    String.prototype.uAddslashes = function(s) {…}
--
    // 文字列の繰り返し
    String.prototype.uRepeat = function(i) {…}
--
    // パスからファイル情報返す @return ['ファイル名','拡張子','拡張子抜きファイル名']
    String.prototype.uGetFileInfo = function() {…}
--
    // パスからファイル名を返す
    String.prototype.uGetFileNameExt = function() {…}
--
    // パスから拡張子を返す
    String.prototype.uGetFileExt = function() {…}
--
    // パスから拡張子抜きファイル名を返す
    String.prototype.uGetFileName = function() {…}
--
    // Math.floor(x)小数点以下指定
    Math.uFloor = function(x, scale) {…}
--
    // Math.ceil(x)小数点以下指定
    Math.uCeil = function(x, scale) {…}
--
    // Math.round(x)小数点以下指定
    Math.uRound = function(x, scale) {…}
--
    // 左空白詰め(右寄せ)
    uLpad = function(txt, pad) {…}
--
    // 右空白詰め(左寄せ)
    uRpad = function(txt, pad) {…}

NodeJS

Code

Result

require('./m-util.js');
var hr = "_".uRepeat(20);

// Here Documents var t = (function() {/* <script> $("*").css("border", "3px solid red"); </script> */}).toString().uHereDoc(); console.log(t); console.log(hr);

var path = 'test.png'; console.log(path.uGetFileInfo()); console.log(path.uGetFileNameExt()); console.log(path.uGetFileExt()); console.log(path.uGetFileName()); console.log(path); console.log(hr);

var path2 = '/Users/mac/Documents/vhosts/m-util/index.js'; console.log(path2.uGetFileInfo()); console.log(path2.uGetFileNameExt()); console.log(path2.uGetFileExt()); console.log(path2.uGetFileName()); console.log(path2); console.log(hr);

console.log(Math.uFloor(124.456, 1)); console.log(Math.uCeil(124.456, 1)); console.log(Math.uRound(124.454, 1)); console.log(Math.uRound(124.455, 1)); console.log(hr);

console.log(Math.uFloor(232.456, 2)); console.log(Math.uCeil(232.456, 2)); console.log(Math.uRound(232.454, 2)); console.log(Math.uRound(232.455, 2)); console.log(hr);

console.log('[' +uRpad("hoge") + ']'); console.log('[' +uLpad("hoge") + ']'); console.log(hr);

console.log('[' +uRpad("fuga", 10) + ']'); console.log('[' +uLpad("fuga", 10) + ']'); console.log(hr);

console.log('[' +escapeHtml('<>`"') + ']'); console.log(hr);

# node example.js

<script> $("*").css("border", "3px solid red"); </script>


[ 'test.png', 'png', 'test' ] test.png png test test.png


[ 'index.js', 'js', 'index' ] index.js js index /Users/mac/Documents/vhosts/m-util/index.js


124.4 124.5 124.5 124.5


232.45 232.46 232.45 232.46


[hoge ] [ hoge]


[fuga ] [ fuga]


[<>`"]


ライセンス - License

MIT License

作者 - Author

Readme

Keywords

Package Sidebar

Install

npm i m-util

Weekly Downloads

0

Version

0.0.11

License

MIT

Last publish

Collaborators

  • m-shibata