Skip to content
This repository was archived by the owner on Jun 23, 2019. It is now read-only.

Commit 621e809

Browse files
committed
🎉 Initial commit
Signed-off-by: Rong Sen Ng <wes.ngrongsen@gmail.com>
0 parents  commit 621e809

17 files changed

+7185
-0
lines changed

.editorconfig

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# http://editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
9+
# Change these settings to your own preference
10+
indent_style = space
11+
indent_size = 2
12+
13+
# We recommend you to keep these unchanged
14+
end_of_line = lf
15+
charset = utf-8
16+
trim_trailing_whitespace = true
17+
insert_final_newline = true
18+
19+
[*.md]
20+
trim_trailing_whitespace = false

.eslintignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
**/*.spec.js
2+
**/*.test.js
3+
**/*test*/**
4+
**/coverage/**
5+
**/build/**
6+
**/dist/**
7+
**/node_modules/**
8+
out/
9+
logs/**/[^.]*

.eslintrc.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"extends": [
3+
"zumata"
4+
],
5+
"plugins": [
6+
],
7+
"root": true,
8+
"rules": {
9+
"camelcase": [
10+
"error",
11+
{ "properties": "never" }
12+
],
13+
"no-bitwise": [
14+
"error",
15+
{ "allow": ["^"] }
16+
],
17+
"no-console": [
18+
"error",
19+
{ "allow": [ "info", "log", "error", "warn" ] }
20+
]
21+
}
22+
}

.gitattributes

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Automatically normalize line endings for all text-based files
2+
# http://git-scm.com/docs/gitattributes#_end_of_line_conversion
3+
* text=auto
4+
5+
# For the following file types, normalize line endings to LF on
6+
# checkin and prevent conversion to CRLF when they are checked out
7+
# (this is required in order to prevent newline related issues like,
8+
# for example, after the build script is run)
9+
.* text eol=lf
10+
*.css text eol=lf
11+
*.html text eol=lf
12+
*.js text eol=lf
13+
*.json text eol=lf
14+
*.scss text eol=lf
15+
*.md text eol=lf
16+
*.sh text eol=lf
17+
*.txt text eol=lf
18+
*.xml text eol=lf
19+
*.yaml text eol=lf
20+
*.yml text eol=lf

.gitignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.DS_Store
2+
*.env
3+
.build/
4+
.nyc_output
5+
.tmp/
6+
.vscode
7+
npm-debug.log*
8+
yarn-error.log*
9+
build/
10+
coverage/
11+
dist/
12+
dist/**/__mocks__/
13+
dist/**/__tests__/
14+
logs/**/[^.]*
15+
node_modules/
16+
out/

.npmignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.DS_Store
2+
*.env
3+
.build/
4+
.nyc_output
5+
.tmp/
6+
.vscode
7+
npm-debug.log*
8+
yarn-error.log*
9+
build/
10+
coverage/
11+
dist*/
12+
dist/**/__mocks__/
13+
dist/**/__tests__/
14+
logs/**/[^.]*
15+
node_modules/
16+
out/

.npmrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# User config
2+
package-lock=true
3+
progress=true
4+
quiet=true
5+
update-binary=true

CONTRIBUTORS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Contributors in no specific order

LICENSE

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
The MIT License (MIT)
2+
Copyright © 2017 Rong Sen Ng <wes_ngrongsen@hotmail.com>
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5+
6+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7+
8+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# tab-align
2+
3+
> Align text with whitespaces
4+
5+
Align text with whitespaces + position.
6+
7+
## Install
8+
9+
```bash
10+
# Install package with NPM
11+
$ npm install --save tab-align
12+
```
13+
14+
## How to use
15+
16+
The following is a simple code snippet:
17+
18+
```js
19+
/** Import the package */
20+
const tabAlign = require('tab-align');
21+
22+
/** Setting up with the position and whitespaces for alignment */
23+
const pos = 'end';
24+
const whitespaces = 4;
25+
const allPossibleTitles = [
26+
'really really long title',
27+
'random title',
28+
'short title',
29+
'how\'s your day',
30+
];
31+
const fillWith = '.';
32+
const alignText = tabAlign(allPossibleTitles, pos, whitespaces, fillWith);
33+
34+
console.log(alignText('Today\'s title'));
35+
// This logs `........................Today's title`
36+
```
37+
38+
## tabAlign(stringArrays, [alignTo, whitespaces, fillWith])
39+
40+
- `stringArrays` <[string][string-mdn-url][]> An array of strings to determine the length of the longest title.
41+
- `alignTo` <[string][string-mdn-url]> Position to align text to. Possible values: `start`, `center`, or `end`.
42+
- `whitespaces` <[number][number-mdn-url]> Number of whitespaces to fill in.
43+
- `fillWith` <[string][string-mdn-url]> Symbol to replace whitespaces during the filling in.
44+
- returns <[Function][function-mdn-url]>
45+
- `text` <[string][string-mdn-url]> Text for alignment.
46+
47+
## License
48+
49+
[MIT License][mit-license-url] © Rong Sen Ng
50+
51+
[mit-license-url]: http://motss.mit-license.org/
52+
53+
[string-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
54+
[number-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number
55+
[function-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function

clean-dir.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
clear; printf "Running %s script...\n" "$(basename "$0" .sh)"
4+
5+
has_unused_directories=false
6+
directories="dist* build/ node_modules/ npm-debug*.log* yarn-error*.log* .nyc_output/ coverage/ out/"
7+
8+
for directory in $directories; do
9+
if [ -d "$directory" ] || [ -f "$directory" ]; then
10+
printf "\nRemoving %s...\n" "$directory"
11+
rm -rf "$directory"
12+
has_unused_directories=true
13+
fi
14+
done
15+
16+
if [ "$has_unused_directories" = true ]; then
17+
printf "\nCleaning done.\n"
18+
else
19+
printf "\nNothing to clean here.\n\n"
20+
fi

gulpfile.js

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
const gulp = require('gulp');
2+
const ts = require('gulp-typescript');
3+
const babel = require('gulp-babel');
4+
const sq = require('gulp-sequence');
5+
const del = require('del');
6+
7+
const isProd = process.env.NODE_ENV === 'production';
8+
const SRC = 'src';
9+
const TMP = '.tmp';
10+
const DIST = 'dist';
11+
const BABELRC = {
12+
presets: [
13+
[
14+
'env',
15+
{
16+
targets: {
17+
node: 'current',
18+
},
19+
spec: true,
20+
modules: 'commonjs',
21+
useBuiltIns: true,
22+
},
23+
],
24+
...(isProd ? [
25+
[
26+
'minify',
27+
{
28+
replace: false,
29+
removeConsole: false,
30+
removeDebugger: true,
31+
},
32+
],
33+
] : []),
34+
],
35+
plugins: [
36+
'transform-function-bind',
37+
'transform-object-rest-spread',
38+
],
39+
ignore: isProd
40+
? [
41+
'**/__mocks*__/*.js',
42+
'**/__tests*__/*.dist.spec.js',
43+
'**/__tests*__/*.spec.js',
44+
]
45+
: [],
46+
};
47+
48+
gulp.task('ts', () =>
49+
gulp.src([
50+
`${SRC}/**/*.ts`,
51+
])
52+
.pipe(ts.createProject('./tsconfig.json')())
53+
.pipe(gulp.dest(TMP)));
54+
55+
gulp.task('babel', () =>
56+
gulp.src([
57+
`${TMP}/**/*.js`,
58+
])
59+
.pipe(babel(BABELRC))
60+
.pipe(gulp.dest(DIST)));
61+
62+
gulp.task('clean', () => del([
63+
TMP,
64+
DIST,
65+
]));
66+
67+
gulp.task('clear', () => del([
68+
TMP,
69+
]));
70+
71+
gulp.task('copy', () => gulp.src([
72+
`${TMP}/**/*`,
73+
`!${TMP}/**/*.js`,
74+
])
75+
.pipe(gulp.dest(DIST)));
76+
77+
gulp.task('watch', () => {
78+
gulp.watch([
79+
`${SRC}/**/*.ts`,
80+
], ['build']);
81+
});
82+
83+
gulp.task('build', ['clean'], cb => sq(...[
84+
'ts',
85+
['babel', 'copy'],
86+
'clear',
87+
])(cb));
88+
89+
gulp.task('default', ['watch'], sq('build'));

0 commit comments

Comments
 (0)