├── .editorconfig ├── .gitattributes ├── .gitignore ├── .jshintignore ├── .jshintrc ├── .npmignore ├── .travis.yml ├── LICENSE ├── Makefile ├── README.md ├── TODO.md ├── examples └── index.js ├── lib └── index.js ├── package.json └── test └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | charset = utf-8 6 | trim_trailing_whitespace = true 7 | insert_final_newline = true 8 | 9 | [*.js] 10 | indent_style = tab 11 | 12 | [*.py] 13 | indent_style = space 14 | 15 | [*.md] 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Files # 3 | ######### 4 | 5 | 6 | # Directories # 7 | ############### 8 | reports/ 9 | build/ 10 | 11 | # Compiled source # 12 | ################### 13 | *.com 14 | *.class 15 | *.dll 16 | *.exe 17 | *.o 18 | *.so 19 | *.slo 20 | *.lo 21 | *.obj 22 | *.dylib 23 | *.dll 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | *.ko 29 | *.elf 30 | 31 | # Precompiled headers # 32 | ####################### 33 | *.gch 34 | *.pch 35 | 36 | # Executables # 37 | ############### 38 | *.exe 39 | *.out 40 | *.app 41 | 42 | # Packages # 43 | ############ 44 | # it's better to unpack these files and commit the raw source 45 | # git has its own built in compression methods 46 | *.7z 47 | *.dmg 48 | *.gz 49 | *.iso 50 | *.jar 51 | *.rar 52 | *.tar 53 | *.zip 54 | 55 | # Logs and databases # 56 | ###################### 57 | *.log 58 | *.sql 59 | *.sqlite 60 | 61 | # OS generated files # 62 | ###################### 63 | .DS_Store 64 | .DS_Store? 65 | ._* 66 | .Spotlight-V100 67 | .Trashes 68 | Icon? 69 | ehthumbs.db 70 | Thumbs.db 71 | Desktop.ini 72 | 73 | # Temporary files # 74 | ################### 75 | *~ 76 | 77 | # Node.js # 78 | ########### 79 | /node_modules/ 80 | pids 81 | *.pid 82 | *.seed 83 | 84 | # Matlab # 85 | ########## 86 | *.asv 87 | *.mex* 88 | 89 | # Fortran # 90 | ########### 91 | *.mod 92 | 93 | # R # 94 | ##### 95 | .Rhistory 96 | .Rapp.history 97 | .Rproj.user/ 98 | 99 | # Python # 100 | ########## 101 | __pycache__/ 102 | *.py[cod] 103 | *$py.class 104 | 105 | # TeX # 106 | ####### 107 | *.aux 108 | *.lof 109 | *.log 110 | *.lot 111 | *.fls 112 | *.out 113 | *.toc 114 | *.dvi 115 | *-converted-to.* 116 | *.bbl 117 | *.bcf 118 | *.blg 119 | *-blx.aux 120 | *-blx.bib 121 | *.brf 122 | *.run.xml 123 | *.fdb_latexmk 124 | *.synctex 125 | *.synctex.gz 126 | *.synctex.gz(busy) 127 | *.pdfsync 128 | *.alg 129 | *.loa 130 | acs-*.bib 131 | *.thm 132 | *.nav 133 | *.snm 134 | *.vrb 135 | *.acn 136 | *.acr 137 | *.glg 138 | *.glo 139 | *.gls 140 | *.brf 141 | *-concordance.tex 142 | *.tikz 143 | *-tikzDictionary 144 | *.idx 145 | *.ilg 146 | *.ind 147 | *.ist 148 | -------------------------------------------------------------------------------- /.jshintignore: -------------------------------------------------------------------------------- 1 | 2 | # Directories # 3 | ############### 4 | build/ 5 | reports/ 6 | dist/ 7 | 8 | # Node.js # 9 | ########### 10 | /node_modules/ 11 | 12 | # Git # 13 | ####### 14 | .git* 15 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "bitwise": false, 3 | "camelcase": false, 4 | "curly": true, 5 | "eqeqeq": true, 6 | "es3": false, 7 | "forin": true, 8 | "freeze": true, 9 | "immed": true, 10 | "indent": 4, 11 | "latedef": "nofunc", 12 | "newcap": true, 13 | "noarg": true, 14 | "noempty": false, 15 | "nonbsp": true, 16 | "nonew": true, 17 | "plusplus": false, 18 | "quotmark": "single", 19 | "undef": true, 20 | "unused": true, 21 | "strict": true, 22 | "maxparams": 10, 23 | "maxdepth": 5, 24 | "maxstatements": 100, 25 | "maxcomplexity": false, 26 | "maxlen": 1000, 27 | "asi": false, 28 | "boss": false, 29 | "debug": false, 30 | "eqnull": false, 31 | "esnext": false, 32 | "evil": false, 33 | "expr": false, 34 | "funcscope": false, 35 | "globalstrict": false, 36 | "iterator": false, 37 | "lastsemic": false, 38 | "laxbreak": false, 39 | "laxcomma": false, 40 | "loopfunc": false, 41 | "maxerr": 1000, 42 | "moz": false, 43 | "multistr": false, 44 | "notypeof": false, 45 | "proto": false, 46 | "scripturl": false, 47 | "shadow": false, 48 | "sub": true, 49 | "supernew": false, 50 | "validthis": false, 51 | "noyield": false, 52 | "browser": true, 53 | "browserify": true, 54 | "couch": false, 55 | "devel": true, 56 | "dojo": false, 57 | "jasmine": false, 58 | "jquery": false, 59 | "mocha": true, 60 | "mootools": false, 61 | "node": true, 62 | "nonstandard": false, 63 | "prototypejs": false, 64 | "qunit": false, 65 | "rhino": false, 66 | "shelljs": false, 67 | "worker": false, 68 | "wsh": false, 69 | "yui": false, 70 | "globals": {} 71 | } -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | 2 | # Files # 3 | ######### 4 | Makefile 5 | README.md 6 | TODO.md 7 | 8 | # Directories # 9 | ############### 10 | build/ 11 | docs/ 12 | examples/ 13 | reports/ 14 | support/ 15 | test/ 16 | benchmark/ 17 | 18 | # Node.js # 19 | ########### 20 | .npmignore 21 | /node_modules/ 22 | 23 | # Logs # 24 | ######## 25 | *.log 26 | 27 | # OS generated files # 28 | ###################### 29 | .DS_Store 30 | .DS_Store? 31 | ._* 32 | .Spotlight-V100 33 | .Trashes 34 | Icon? 35 | ehthumbs.db 36 | Thumbs.db 37 | Desktop.ini 38 | 39 | # Temporary files # 40 | ################### 41 | *~ 42 | 43 | # Git # 44 | ####### 45 | .git* 46 | 47 | # Utilities # 48 | ############# 49 | .jshintrc 50 | .jshintignore 51 | .eslintrc 52 | .travis.yml 53 | circle.yml 54 | .editorconfig 55 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 'stable' 4 | - '5' 5 | - '4' 6 | - '0.12' 7 | - '0.10' 8 | - 'iojs' 9 | before_install: 10 | - npm update -g npm 11 | after_script: 12 | - npm run coverage 13 | 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 The Compute.io Authors. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############# 3 | # VARIABLES # 4 | 5 | # Set the node.js environment to test: 6 | NODE_ENV ?= test 7 | 8 | # Kernel name: 9 | KERNEL ?= $(shell uname -s) 10 | 11 | ifeq ($(KERNEL), Darwin) 12 | OPEN ?= open 13 | else 14 | OPEN ?= xdg-open 15 | endif 16 | 17 | 18 | # NOTES # 19 | 20 | NOTES ?= 'TODO|FIXME|WARNING|HACK|NOTE' 21 | 22 | 23 | # TAPE # 24 | 25 | TAPE ?= ./node_modules/.bin/tape 26 | TAP_REPORTER ?= ./node_modules/.bin/tap-spec 27 | 28 | 29 | # ISTANBUL # 30 | 31 | ISTANBUL ?= ./node_modules/.bin/istanbul 32 | ISTANBUL_OUT ?= ./reports/coverage 33 | ISTANBUL_REPORT ?= lcov 34 | ISTANBUL_LCOV_INFO_PATH ?= $(ISTANBUL_OUT)/lcov.info 35 | ISTANBUL_HTML_REPORT_PATH ?= $(ISTANBUL_OUT)/lcov-report/index.html 36 | 37 | 38 | # BROWSERIFY # 39 | 40 | BROWSERIFY ?= ./node_modules/.bin/browserify 41 | 42 | 43 | # TESTLING # 44 | 45 | TESTLING ?= ./node_modules/.bin/testling 46 | TESTLING_DIR ?= ./ 47 | 48 | 49 | # JSHINT # 50 | 51 | JSHINT ?= ./node_modules/.bin/jshint 52 | JSHINT_REPORTER ?= ./node_modules/jshint-stylish 53 | 54 | 55 | 56 | # FILES # 57 | 58 | # Source files: 59 | SOURCES ?= lib/*.js 60 | 61 | # Test files: 62 | TESTS ?= test/*.js 63 | 64 | 65 | 66 | 67 | ########### 68 | # TARGETS # 69 | 70 | 71 | # NOTES # 72 | 73 | .PHONY: notes 74 | 75 | notes: 76 | grep -Ern $(NOTES) $(SOURCES) $(TESTS) 77 | 78 | 79 | 80 | # UNIT TESTS # 81 | 82 | .PHONY: test test-tape 83 | 84 | test: test-tape 85 | 86 | test-tape: node_modules 87 | NODE_ENV=$(NODE_ENV) \ 88 | NODE_PATH=$(NODE_PATH_TEST) \ 89 | $(TAPE) \ 90 | "$(TESTS)" \ 91 | | $(TAP_REPORTER) 92 | 93 | 94 | 95 | # CODE COVERAGE # 96 | 97 | .PHONY: test-cov test-istanbul-tape 98 | 99 | test-cov: test-istanbul-tape 100 | 101 | test-istanbul-tape: node_modules 102 | NODE_ENV=$(NODE_ENV) \ 103 | NODE_PATH=$(NODE_PATH_TEST) \ 104 | $(ISTANBUL) cover \ 105 | --dir $(ISTANBUL_OUT) \ 106 | --report $(ISTANBUL_REPORT) \ 107 | $(TAPE) -- \ 108 | "$(TESTS)" 109 | 110 | 111 | 112 | # COVERAGE REPORT # 113 | 114 | .PHONY: view-cov view-istanbul-report 115 | 116 | view-cov: view-istanbul-report 117 | 118 | view-istanbul-report: 119 | $(OPEN) $(ISTANBUL_HTML_REPORT_PATH) 120 | 121 | 122 | 123 | # BROWSER TESTS # 124 | 125 | .PHONY: test-browsers test-testling view-browser-tests view-testling 126 | 127 | test-browsers: test-testling 128 | 129 | test-testling: node_modules 130 | NODE_ENV=$(NODE_ENV) \ 131 | NODE_PATH=$(NODE_PATH_TEST) \ 132 | $(BROWSERIFY) \ 133 | $(TESTS) \ 134 | | $(TESTLING) \ 135 | | $(TAP_REPORTER) 136 | 137 | view-browser-tests: view-testling 138 | 139 | view-testling: node_modules 140 | NODE_ENV=$(NODE_ENV) \ 141 | NODE_PATH=$(NODE_PATH_TEST) \ 142 | $(BROWSERIFY) \ 143 | $(TESTS) \ 144 | | $(TESTLING) \ 145 | --x $(OPEN) \ 146 | | $(TAP_REPORTER) 147 | 148 | 149 | 150 | # LINT # 151 | 152 | .PHONY: lint lint-jshint 153 | 154 | lint: lint-jshint 155 | 156 | lint-jshint: node_modules 157 | $(JSHINT) \ 158 | --reporter $(JSHINT_REPORTER) \ 159 | ./ 160 | 161 | 162 | # NODE # 163 | 164 | # Install node_modules: 165 | .PHONY: install 166 | 167 | install: 168 | npm install 169 | 170 | # Clean node: 171 | .PHONY: clean-node 172 | 173 | clean-node: 174 | rm -rf node_modules 175 | 176 | 177 | 178 | # CLEAN # 179 | 180 | .PHONY: clean 181 | 182 | clean: 183 | rm -rf build 184 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Pi 2 | === 3 | [![NPM version][npm-image]][npm-url] [![Build Status][build-image]][build-url] [![Coverage Status][coverage-image]][coverage-url] [![Dependencies][dependencies-image]][dependencies-url] 4 | 5 | > [Pi][pi]. 6 | 7 | 8 | ## Installation 9 | 10 | ``` bash 11 | $ npm install const-pi 12 | ``` 13 | 14 | 15 | ## Usage 16 | 17 | ``` javascript 18 | var pi = require( 'const-pi' ); 19 | ``` 20 | 21 | #### pi 22 | 23 | The mathematical constant [pi][pi]. 24 | 25 | ``` javascript 26 | pi === 3.141592653589793; 27 | ``` 28 | 29 | 30 | ## Examples 31 | 32 | ``` javascript 33 | var pi = require( 'const-pi' ); 34 | 35 | console.log( pi ); 36 | ``` 37 | 38 | To run the example code from the top-level application directory, 39 | 40 | ``` bash 41 | $ node ./examples/index.js 42 | ``` 43 | 44 | 45 | --- 46 | ## Tests 47 | 48 | ### Unit 49 | 50 | This repository uses [tape][tape] for unit tests. To run the tests, execute the following command in the top-level application directory: 51 | 52 | ``` bash 53 | $ make test 54 | ``` 55 | 56 | All new feature development should have corresponding unit tests to validate correct functionality. 57 | 58 | 59 | ### Test Coverage 60 | 61 | This repository uses [Istanbul][istanbul] as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory: 62 | 63 | ``` bash 64 | $ make test-cov 65 | ``` 66 | 67 | Istanbul creates a `./reports/coverage` directory. To access an HTML version of the report, 68 | 69 | ``` bash 70 | $ make view-cov 71 | ``` 72 | 73 | 74 | ### Browser Support 75 | 76 | This repository uses [Testling][testling] for browser testing. To run the tests in a (headless) local web browser, execute the following command in the top-level application directory: 77 | 78 | ``` bash 79 | $ make test-browsers 80 | ``` 81 | 82 | To view the tests in a local web browser, 83 | 84 | ``` bash 85 | $ make view-browser-tests 86 | ``` 87 | 88 | 89 | 90 | 91 | --- 92 | ## License 93 | 94 | [MIT license](http://opensource.org/licenses/MIT). 95 | 96 | 97 | ## Copyright 98 | 99 | Copyright © 2016. The [Compute.io][compute-io] Authors.. 100 | 101 | 102 | [npm-image]: http://img.shields.io/npm/v/const-pi.svg 103 | [npm-url]: https://npmjs.org/package/const-pi 104 | 105 | [build-image]: http://img.shields.io/travis/const-io/pi/master.svg 106 | [build-url]: https://travis-ci.org/const-io/pi 107 | 108 | [coverage-image]: https://img.shields.io/codecov/c/github/const-io/pi/master.svg 109 | [coverage-url]: https://codecov.io/github/const-io/pi?branch=master 110 | 111 | [dependencies-image]: http://img.shields.io/david/const-io/pi.svg 112 | [dependencies-url]: https://david-dm.org/const-io/pi 113 | 114 | [dev-dependencies-image]: http://img.shields.io/david/dev/const-io/pi.svg 115 | [dev-dependencies-url]: https://david-dm.org/dev/const-io/pi 116 | 117 | [github-issues-image]: http://img.shields.io/github/issues/const-io/pi.svg 118 | [github-issues-url]: https://github.com/const-io/pi/issues 119 | 120 | [tape]: https://github.com/substack/tape 121 | [istanbul]: https://github.com/gotwarlost/istanbul 122 | [testling]: https://ci.testling.com 123 | 124 | [compute-io]: https://github.com/compute-io/ 125 | [pi]: https://en.wikipedia.org/wiki/Pi 126 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | TODO 2 | ==== 3 | 4 | -------------------------------------------------------------------------------- /examples/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var pi = require( './../lib' ); 4 | 5 | console.log( pi ); 6 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // EXPORTS // 4 | 5 | module.exports = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679; 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "const-pi", 3 | "version": "1.0.3", 4 | "description": "Pi.", 5 | "author": { 6 | "name": "Athan Reines", 7 | "email": "kgryte@gmail.com" 8 | }, 9 | "contributors": [ 10 | { 11 | "name": "Athan Reines", 12 | "email": "kgryte@gmail.com" 13 | } 14 | ], 15 | "scripts": { 16 | "test": "if [ \"${TRAVIS}\" ]; then npm run test-ci; else npm run test-local; fi", 17 | "test-local": "tape \"./test/*.js\" | tap-spec", 18 | "test-ci": "npm run test-local && xvfb-run npm run test-browsers", 19 | "test-cov": "istanbul cover --dir ./reports/coverage --report lcov tape -- \"./test/*.js\"", 20 | "test-browsers": "browserify ./test/*.js | testling | tap-spec", 21 | "coverage": "istanbul cover --dir ./reports/codecov/coverage --report lcovonly tape -- \"./test/*.js\" && cat ./reports/codecov/coverage/lcov.info | codecov && rm -rf ./reports/codecov" 22 | }, 23 | "main": "./lib", 24 | "repository": { 25 | "type": "git", 26 | "url": "git://github.com/const-io/pi.git" 27 | }, 28 | "keywords": [ 29 | "const-io", 30 | "const.io", 31 | "compute.io", 32 | "compute-io", 33 | "computation", 34 | "compute", 35 | "mathematics", 36 | "math", 37 | "constant", 38 | "const", 39 | "pi" 40 | ], 41 | "bugs": { 42 | "url": "https://github.com/const-io/pi/issues" 43 | }, 44 | "dependencies": {}, 45 | "devDependencies": { 46 | "browserify": "12.x.x", 47 | "codecov": "1.x.x", 48 | "istanbul": "^0.4.1", 49 | "jshint": "2.x.x", 50 | "jshint-stylish": "2.x.x", 51 | "tap-spec": "4.x.x", 52 | "tape": "4.x.x", 53 | "testling": "1.x.x" 54 | }, 55 | "testling": { 56 | "files": [ 57 | "test/*.js" 58 | ], 59 | "browsers": [ 60 | "iexplore/6.0..latest", 61 | "firefox/3.0..latest", 62 | "firefox/nightly", 63 | "chrome/4.0..latest", 64 | "chrome/canary", 65 | "opera/10.0..latest", 66 | "opera/next", 67 | "safari/4.0..latest", 68 | "ipad/6.0..latest", 69 | "iphone/6.0..latest", 70 | "android-browser/4.2..latest" 71 | ] 72 | }, 73 | "license": "MIT" 74 | } 75 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // MODULES // 4 | 5 | var test = require( 'tape' ); 6 | var pi = require( './../lib' ); 7 | 8 | 9 | // TESTS // 10 | 11 | test( 'main export is a number', function test( t ) { 12 | t.ok( typeof pi === 'number', 'main export is a number' ); 13 | t.end(); 14 | }); 15 | 16 | test( 'export is a double-precision floating-point number equal to 3.141592653589793', function test( t ) { 17 | t.equal( pi, 3.141592653589793, 'equals 3.141592653589793' ); 18 | t.end(); 19 | }); 20 | --------------------------------------------------------------------------------