Skip to content

Commit 95df29e

Browse files
authored
Initial (#1)
Initial implementation
1 parent b4dbc26 commit 95df29e

File tree

9 files changed

+939
-37
lines changed

9 files changed

+939
-37
lines changed

.gitignore

+6-37
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,6 @@
1-
# Logs
2-
logs
3-
*.log
4-
npm-debug.log*
5-
6-
# Runtime data
7-
pids
8-
*.pid
9-
*.seed
10-
11-
# Directory for instrumented libs generated by jscoverage/JSCover
12-
lib-cov
13-
14-
# Coverage directory used by tools like istanbul
15-
coverage
16-
17-
# nyc test coverage
18-
.nyc_output
19-
20-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21-
.grunt
22-
23-
# node-waf configuration
24-
.lock-wscript
25-
26-
# Compiled binary addons (http://nodejs.org/api/addons.html)
27-
build/Release
28-
29-
# Dependency directories
30-
node_modules
31-
jspm_packages
32-
33-
# Optional npm cache directory
34-
.npm
35-
36-
# Optional REPL history
37-
.node_repl_history
1+
/bower_components/
2+
/node_modules/
3+
/.pulp-cache/
4+
/output/
5+
/.psci*
6+
/src/.webpack.js

.travis.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: node_js
2+
dist: trusty
3+
sudo: required
4+
node_js:
5+
- 6
6+
install:
7+
- npm install pulp bower -g
8+
- npm install && bower install
9+
script:
10+
- pulp test

README.md

+47
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,49 @@
11
# purescript-formatters
22
Replacement for numeral.js, moment.js etc
3+
4+
## Number formatters
5+
6+
Formatter has following properties
7+
+ Number of digits before dot
8+
+ Number of digits after dot
9+
+ Should sign be printed for positive numbers
10+
+ Should thousands be separated by comma
11+
+ Should output string have abbreviations (like `K` or `M`)
12+
13+
Number will be padded with zeros to have at least this number of leading zeros.
14+
This doesn't restrict number to have more digits then leading zeros in format string.
15+
+ `0000.0` will show 4 digits: `12 -> "0012.0"`, `1234 -> "1234.0"`
16+
+ `00.0` will show only 2 digits : `12 -> "12.0"`, `1234 -> "1234.0"`
17+
18+
Number of digits after dot is set by number of trailing zeros (note the rounding)
19+
+ `0.000` will show 3 digits: `0.12345 -> "0.123"`, `12.98765 -> "12.988"`
20+
+ `0.0` will show only 1 digit: `0.12345 -> "0.1"`, `12.98765 -> "13.0"`
21+
22+
If number is lesser then zero `-` is always printed. Otherwise you could specify `+` in format string
23+
+ `+0`: `12.0 -> "+12"`, `-34.8 -> "-35"`
24+
+ `0`: `12.0 -> "12"`, `-34.8 -> "-35"`
25+
26+
Thousands separator is specified as `,0` please note that this `0` isn't counted as leading.
27+
+ `00,0`: `1234567890 -> "1,234,567,890.0", `1 -> "1.0"`
28+
29+
For abbreviation one could use `a` flag. In general it tries to find the closest power of thousand and
30+
then use formatter to result of division of input number and that power.
31+
+ `0a`: `1234567 -> "1M"`, `1 -> "1"`
32+
33+
## Date/Time formatters
34+
35+
This is just subset of format/parse string from moment.js library. Currently supported
36+
+ `YYYY`
37+
+ `YY`
38+
+ `MMMM`
39+
+ `MMM`
40+
+ `MM`
41+
+ `DD`
42+
+ `X`
43+
+ `E`
44+
+ `HH`
45+
+ `hh`
46+
+ `a`
47+
+ `mm`
48+
+ `ss`
49+
+ `SSS`

bower.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "purescript-formatters",
3+
"ignore": [
4+
"**/.*",
5+
"node_modules",
6+
"bower_components",
7+
"output"
8+
],
9+
"dependencies": {
10+
"purescript-console": "^1.0.0",
11+
"purescript-arrays": "^1.0.0",
12+
"purescript-tuples": "^1.0.0",
13+
"purescript-maybe": "^1.0.0",
14+
"purescript-either": "^1.0.0",
15+
"purescript-parsing": "^1.0.0",
16+
"purescript-fixed-points": "^1.0.0",
17+
"purescript-const": "^1.0.0",
18+
"purescript-datetime": "^1.0.0"
19+
},
20+
"devDependencies": {
21+
"purescript-psci-support": "^1.0.0",
22+
"purescript-debug": "^1.0.0"
23+
}
24+
}

package.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "purescript-formatters",
3+
"description": "Replacement for numeral.js, moment.js etc",
4+
"repository": {
5+
"type": "git",
6+
"url": "https://github.com/slamdata/purescript-formatters"
7+
},
8+
"contributors": [
9+
"Maxim Zimaliev <[email protected]>"
10+
],
11+
"license": "Apache-2.0",
12+
"bugs": {
13+
"url": "https://github.com/slamdata/purescript-formatters/issues"
14+
},
15+
"homepage": "https://github.com/slamdata/purescript-formatters#readme",
16+
"dependencies": {
17+
"pulp": "^9.0.1",
18+
"purescript": "^0.9.1",
19+
"purescript-psa": "^0.3.9"
20+
}
21+
}

0 commit comments

Comments
 (0)