1- /* eslint no-bitwise: ["error", { "allow": ["|"] }] */
21const { randomFillSync } = require ( 'crypto' ) ;
2+
3+ /**
4+ * Joined the inputs by a `Line Feed`(LF) char.
5+ *
6+ * @param {(string|number)[] } pieces - The string(s) joined by line feed.
7+ *
8+ * @returns {string } - The joined string.
9+ */
10+ function joinedByLineFeed ( ...pieces ) {
11+ return [ ] . concat ( pieces , '' ) . join ( '\n' ) ;
12+ }
13+
314/**
415 * Provides easy used methods using in this project.
516 */
@@ -12,7 +23,7 @@ class Formatter {
1223 * @returns {object } - The casted source intputs as {rows, summary} Object
1324 */
1425 static castCsvBill ( buffer ) {
15- const data = Buffer . from ( buffer ) . slice ( 3 /* BOM(EFBBBF) */ ) . toString ( ) . split ( / \r ? \n / ) ;
26+ const data = Buffer . from ( buffer ) . subarray ( 3 /* BOM(EFBBBF) */ ) . toString ( ) . split ( / \r ? \n / ) ;
1627 const list = data . slice ( 1 , - 3 ) ;
1728 const foot = data . slice ( - 3 ) ;
1829 const head = data . shift ( ) . split ( ',' ) ;
@@ -57,7 +68,7 @@ class Formatter {
5768 * @returns {number } Epoch timestamp.
5869 */
5970 static timestamp ( ) {
60- return Date . now ( ) / 1000 | 0 ;
71+ return Math . floor ( Date . now ( ) / 1000 ) ;
6172 }
6273
6374 /**
@@ -87,7 +98,7 @@ class Formatter {
8798 * @returns {string } - The content for `Rsa.sign`
8899 */
89100 static request ( method , uri , timestamp , nonce , body = '' ) {
90- return this . joinedByLineFeed ( method , uri , timestamp , nonce , body ) ;
101+ return joinedByLineFeed ( method , uri , timestamp , nonce , body ) ;
91102 }
92103
93104 /**
@@ -100,19 +111,10 @@ class Formatter {
100111 * @returns {string } - The content for `Rsa.verify`
101112 */
102113 static response ( timestamp , nonce , body = '' ) {
103- return this . joinedByLineFeed ( timestamp , nonce , body ) ;
114+ return joinedByLineFeed ( timestamp , nonce , body ) ;
104115 }
105116
106- /**
107- * Joined this inputs by for `Line Feed`(LF) char.
108- *
109- * @param {string[] } pieces - The string(s) joined by line feed.
110- *
111- * @returns {string } - The joined string.
112- */
113- static joinedByLineFeed ( ...pieces ) {
114- return [ ...pieces , '' ] . join ( '\n' ) ;
115- }
117+ static joinedByLineFeed = joinedByLineFeed
116118
117119 /**
118120 * Sorts an Object by key.
0 commit comments