├── lwt-node.opam ├── jbuild-ignore ├── bin ├── Index.re └── jbuild ├── website ├── static │ ├── img │ │ ├── favicon.png │ │ ├── readme.png │ │ ├── favicon │ │ │ └── favicon.ico │ │ ├── reasonNodePrimary.png │ │ ├── slash-introducing.png │ │ ├── reasonNode.svg │ │ ├── reasonNodePrimary.svg │ │ └── reasonNodeHero.svg │ ├── css │ │ └── custom.css │ └── nodes.js ├── sidebars.json ├── .gitignore ├── core │ └── Footer.js ├── package.json ├── i18n │ └── en.json ├── crowdin.yaml ├── pages │ └── en │ │ ├── users.js │ │ ├── help.js │ │ └── index.js ├── siteConfig.js ├── blog │ └── 2017-12-31-initial-release.md └── languages.js ├── src ├── lwtNode.re ├── jbuild ├── node.rei ├── node.re ├── path.rei ├── process.re ├── fs.re ├── path.re ├── renodeUtils.re ├── process.rei └── fs.rei ├── tests ├── jbuild ├── test.re ├── fsTests.re ├── pathTests.re └── renodeUtilsTests.re ├── .travis.yml ├── ROADMAP.md ├── docs ├── introExample.md ├── whatWhy.md ├── installation.md ├── node.md ├── path.md ├── process.md └── fs.md ├── Makefile ├── .gitignore ├── package.json ├── Future.md ├── .npmignore ├── LICENSE ├── README.md ├── CONTRIBUTING.md └── esy.lock /lwt-node.opam: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /jbuild-ignore: -------------------------------------------------------------------------------- 1 | node_modules/** 2 | node_modules 3 | .git 4 | .git/** -------------------------------------------------------------------------------- /bin/Index.re: -------------------------------------------------------------------------------- 1 | open LwtNode; 2 | 3 | Node.run(ignore(Fs.mkdir("myDir"))); -------------------------------------------------------------------------------- /website/static/img/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kennetpostigo/lwt-node/HEAD/website/static/img/favicon.png -------------------------------------------------------------------------------- /website/static/img/readme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kennetpostigo/lwt-node/HEAD/website/static/img/readme.png -------------------------------------------------------------------------------- /bin/jbuild: -------------------------------------------------------------------------------- 1 | (jbuild_version 1) 2 | 3 | (executable 4 | ((name Index) 5 | (public_name Index) 6 | (libraries (lwt-node)))) -------------------------------------------------------------------------------- /website/static/img/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kennetpostigo/lwt-node/HEAD/website/static/img/favicon/favicon.ico -------------------------------------------------------------------------------- /website/static/img/reasonNodePrimary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kennetpostigo/lwt-node/HEAD/website/static/img/reasonNodePrimary.png -------------------------------------------------------------------------------- /website/static/img/slash-introducing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kennetpostigo/lwt-node/HEAD/website/static/img/slash-introducing.png -------------------------------------------------------------------------------- /src/lwtNode.re: -------------------------------------------------------------------------------- 1 | module Fs = Fs; 2 | 3 | module Node = Node; 4 | 5 | module Path = Path; 6 | 7 | module Process = Process; 8 | 9 | module RenodeUtils = RenodeUtils; -------------------------------------------------------------------------------- /website/sidebars.json: -------------------------------------------------------------------------------- 1 | { 2 | "docs": { 3 | "Getting Started": ["whatWhy", "installation", "introExample"], 4 | "API": ["fs", "node", "path", "process"] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jbuild: -------------------------------------------------------------------------------- 1 | (jbuild_version 1) 2 | 3 | (library 4 | ((name LwtNode) 5 | (public_name lwt-node) 6 | (libraries (lwt.unix)) 7 | (preprocess (pps (bisect_ppx -conditional))))) 8 | -------------------------------------------------------------------------------- /tests/jbuild: -------------------------------------------------------------------------------- 1 | (jbuild_version 1) 2 | 3 | (executable 4 | ((name test) 5 | (libraries (lwt-node alcotest)))) 6 | 7 | (alias 8 | ((name runtest) 9 | (deps (test.exe)) 10 | (action (run ${<})))) 11 | -------------------------------------------------------------------------------- /tests/test.re: -------------------------------------------------------------------------------- 1 | let () = 2 | Alcotest.run( 3 | ~argv=[|"--verbose --color"|], 4 | "LwtNode", 5 | [ 6 | ("PathTests", PathTests.pathTestSet), 7 | ("RenodeUtilsTests", RenodeUtilsTests.utilsTestSet) 8 | ] 9 | ); -------------------------------------------------------------------------------- /website/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | lib/core/metadata.js 4 | lib/core/MetadataBlog.js 5 | website/translated_docs 6 | website/build/ 7 | website/yarn.lock 8 | website/node_modules 9 | 10 | website/i18n/* 11 | !website/i18n/en.json 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | os: 3 | - linux 4 | - osx 5 | node_js: 6 | - "8" 7 | - "6" 8 | install: 9 | - travis_retry npm install -g esy@latest 10 | script: 11 | - esy install 12 | - esy build 13 | - esy make test 14 | cache: 15 | - $HOME/.esy -------------------------------------------------------------------------------- /tests/fsTests.re: -------------------------------------------------------------------------------- 1 | open LwtNode; 2 | 3 | /* let basenameNoExt () => 4 | Alcotest.(check string) 5 | "Path.basename without ext arg" "quux.html" (Path.basename "/foo/bar/baz/asdf/quux.html"); */ 6 | let fsTestSet = []; 7 | /* ("Path.basename without ext arg", `Slow, basenameNoExt), */ -------------------------------------------------------------------------------- /src/node.rei: -------------------------------------------------------------------------------- 1 | type t('a) = Lwt.t('a); 2 | 3 | let andThen: (t('a), 'a => t('b)) => t('b); 4 | 5 | let catch: (unit => t('a), exn => t('a)) => t('a); 6 | 7 | let resolved: 'a => t('a); 8 | 9 | let fail: exn => t('a); 10 | 11 | let cancel: t('a) => unit; 12 | 13 | let run: 'a => unit; 14 | 15 | let stop: unit => unit; -------------------------------------------------------------------------------- /src/node.re: -------------------------------------------------------------------------------- 1 | type t('a) = Lwt.t('a); 2 | 3 | let andThen = Lwt.bind; 4 | 5 | let catch = Lwt.catch; 6 | 7 | let resolved = Lwt.return; 8 | 9 | let fail = Lwt.fail; 10 | 11 | let cancel = Lwt.cancel; 12 | 13 | let (until_done, signal_done) = Lwt.wait(); 14 | 15 | let run = (app) => Lwt_main.run(until_done); 16 | 17 | let stop = () => Lwt.wakeup_later(signal_done, ()); -------------------------------------------------------------------------------- /ROADMAP.md: -------------------------------------------------------------------------------- 1 | # Roadmap 2 | 3 | If you are interested in what is next for lwt-node, you're in the right place! 4 | 5 | ### Modules up next 6 | 7 | * http 8 | * stream 9 | * child process 10 | * crypto 11 | 12 | ## Goals 13 | 14 | * Get missing implementation of existing modules done (listed in (https://github.com/kennetpostigo/lwt-node/blob/master/Future.md)) 15 | * Get http and stream major/most used portions of their API completed. 16 | -------------------------------------------------------------------------------- /docs/introExample.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: introExample 3 | title: Intro Example 4 | sidebar_label: Intro Example 5 | --- 6 | 7 | Here is a small overview of the `lwt-node` API before we start. No worries if some of these are unfamiliar; the docs cover all of them. 8 | 9 | ```reason 10 | open LwtNode; 11 | 12 | Node.run({ 13 | let%lwt myDir = Fs.mkdir("myDir"); 14 | let%lwt myDir2 = Fs.mkdir("myDir2"); 15 | Node.resolved(); 16 | }); 17 | ``` 18 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | test: 2 | jbuilder runtest 3 | 4 | run: 5 | ./_build/install/default/bin/Index 6 | 7 | .PHONY: coverage 8 | coverage: clean 9 | BISECT_ENABLE=YES jbuilder build 10 | jbuilder runtest 11 | bisect-ppx-report -ignore-missing-files -I _build/default/ -html coverage/ \ 12 | _build/default/tests/bisect*.out 13 | @echo See ./coverage/index.html 14 | 15 | clean: 16 | rm -f _build/default/tests/bisect*.out 17 | rm -rf _build *.install 18 | -------------------------------------------------------------------------------- /website/core/Footer.js: -------------------------------------------------------------------------------- 1 | const React = require("react"); 2 | 3 | class Footer extends React.Component { 4 | docUrl(doc, language) { 5 | const baseUrl = this.props.config.baseUrl; 6 | return baseUrl + "docs/" + (language ? language + "/" : "") + doc; 7 | } 8 | 9 | pageUrl(doc, language) { 10 | const baseUrl = this.props.config.baseUrl; 11 | return baseUrl + (language ? language + "/" : "") + doc; 12 | } 13 | 14 | render() { 15 | return null; 16 | } 17 | } 18 | 19 | module.exports = Footer; 20 | -------------------------------------------------------------------------------- /docs/whatWhy.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: whatWhy 3 | title: What & Why 4 | sidebar_label: What & Why 5 | --- 6 | 7 | `lwt-node` is a safer, faster way to build systems/server applications. 8 | 9 | By leveraging `reason`'s great type system, expressive language features, 10 | `lwt-node` implements a node.js like API that is: 11 | 12 | * Fast 13 | * Safe and statically typed 14 | * Simple and lean 15 | 16 | The goal is to eventually reach feature parity with the node.js API. 17 | These will be filled in incrementally as the API is smoothed out. 18 | -------------------------------------------------------------------------------- /docs/installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: installation 3 | title: Installation 4 | sidebar_label: Installation 5 | --- 6 | 7 | First you need to install [esy](https://github.com/esy/), Sandboxed and project based installations that share build artifacts and builds, for lightning fast installations and incremental builds: 8 | 9 | ```bash 10 | yarn global add esy 11 | 12 | # OR with npm 13 | 14 | npm install --global esy 15 | ``` 16 | 17 | Then go ahead and add lwt-node to your project with esy: 18 | 19 | ```bash 20 | esy add lwt-node 21 | ``` 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | 6 | # testing 7 | /coverage 8 | 9 | # production 10 | /build 11 | 12 | # misc 13 | .DS_Store 14 | .env.local 15 | .env.development.local 16 | .env.test.local 17 | .env.production.local 18 | 19 | npm-debug.log* 20 | yarn-debug.log* 21 | yarn-error.log* 22 | 23 | lib 24 | node_modules 25 | build 26 | _build 27 | coverage 28 | bisect*.out 29 | .DS_Store 30 | _build/** 31 | *~ 32 | *.cmi 33 | *.exe 34 | *.cmo 35 | *.cmx 36 | *.cma 37 | *.cmxa 38 | *.cmxs 39 | *.a 40 | *.o 41 | *.annot 42 | *.run 43 | *.opt 44 | *.native 45 | *.byte 46 | *.install 47 | pkg/META 48 | .merlin 49 | /node_modules/ 50 | -------------------------------------------------------------------------------- /website/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "examples": "docusaurus-examples", 4 | "start": "docusaurus-start", 5 | "build": "docusaurus-build", 6 | "publish-gh-pages": 7 | "GIT_USER=kennetpostigo CURRENT_BRANCH=master docusaurus-publish", 8 | "write-translations": "docusaurus-write-translations", 9 | "version": "docusaurus-version", 10 | "rename-version": "docusaurus-rename-version" 11 | }, 12 | "author": "Kennet Postigo ", 13 | "repository": { 14 | "type": "git", 15 | "url": "git+https://github.com/kennetpostigo/reason-node.git" 16 | }, 17 | "dependencies": { 18 | "resaurus": "rickyvetter/resaurus" 19 | }, 20 | "devDependencies": { 21 | "docusaurus": "^1.0.4" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/path.rei: -------------------------------------------------------------------------------- 1 | let basename: (~ext: string=?, string) => string; 2 | 3 | let delimeter: string; 4 | 5 | let sep: string; 6 | 7 | let dirname: string => string; 8 | 9 | let extname: string => string; 10 | 11 | type pathObject = { 12 | dir: option(string), 13 | root: option(string), 14 | base: option(string), 15 | name: option(string), 16 | ext: option(string) 17 | }; 18 | 19 | let format: pathObject => string; 20 | 21 | let isAbsolute: string => bool; 22 | 23 | let join: list(string) => string; 24 | 25 | let normalize: string => string; 26 | 27 | let parse: string => pathObject; 28 | 29 | let relative: (~from: string, ~_to: string) => string; 30 | 31 | let relativeFilePath: (~from: string, ~_to: string) => string; 32 | 33 | let resolve: list(string) => string; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lwt-node", 3 | "version": "0.2.0", 4 | "description": "Lwt Node - a node.js like API for Native", 5 | "license": "MIT", 6 | "esy": { 7 | "build": [["refmterr", "jbuilder", "build"]], 8 | "install": ["esy-installer"], 9 | "buildsInSource": "_build" 10 | }, 11 | "dependencies": { 12 | "@esy-ocaml/esy-installer": "^0.0.0", 13 | "@opam/alcotest": "*", 14 | "@opam/bisect_ppx": "*", 15 | "@opam/jbuilder": "*", 16 | "@opam/lwt": "~3.2.0", 17 | "@opam/reason": "3.0.4", 18 | "refmterr": "3.0.4" 19 | }, 20 | "peerDependencies": { 21 | "ocaml": " >= 4.2.0 < 4.7.0" 22 | }, 23 | "devDependencies": { 24 | "@opam/merlin": "*", 25 | "ocaml": "~4.6.1" 26 | }, 27 | "resolutions": { 28 | "**/@opam/result": "1.2.0" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Future.md: -------------------------------------------------------------------------------- 1 | # Path 2 | + relative 3 | 4 | # FS 5 | + appendFile 6 | + appendFileSync 7 | + createReadStream 8 | + createWriteStream 9 | + fdatasyncSync 10 | + fsyncSync 11 | + futimes 12 | + futimesSync 13 | + lchmod 14 | + lchmodSync 15 | + lchown 16 | + lchownSync 17 | + mkdtemp 18 | + mkdtempSync 19 | + readFile 20 | + readFileSync 21 | + realpath 22 | + realpathSync 23 | + unwatchFile 24 | + watch 25 | + watchFile 26 | + writeFile 27 | + writeFileSync 28 | 29 | # Process 30 | + abort 31 | + arch 32 | + channel 33 | + config 34 | + connected 35 | + cpuUsage 36 | + disconnect 37 | + emitWarning 38 | + hrtime 39 | + mainModule 40 | + memoryUsage 41 | + nextTick 42 | + platform 43 | + release 44 | + setegid 45 | + seteuid 46 | + stderr 47 | + stdin 48 | + stdout 49 | + title 50 | + unmask 51 | + uptime 52 | + version 53 | + versions 54 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # New additions that will make npm install longer 2 | /future.md 3 | /website 4 | /docs 5 | 6 | 7 | # from gitignore 8 | # See https://help.github.com/ignore-files/ for more about ignoring files. 9 | 10 | # dependencies 11 | /node_modules 12 | 13 | # testing 14 | /coverage 15 | 16 | # production 17 | /build 18 | 19 | # misc 20 | .DS_Store 21 | .env.local 22 | .env.development.local 23 | .env.test.local 24 | .env.production.local 25 | 26 | npm-debug.log* 27 | yarn-debug.log* 28 | yarn-error.log* 29 | 30 | lib 31 | node_modules 32 | build 33 | _build 34 | coverage 35 | bisect*.out 36 | .DS_Store 37 | _build/** 38 | *~ 39 | *.cmi 40 | *.exe 41 | *.cmo 42 | *.cmx 43 | *.cma 44 | *.cmxa 45 | *.cmxs 46 | *.a 47 | *.o 48 | *.annot 49 | *.run 50 | *.opt 51 | *.native 52 | *.byte 53 | *.install 54 | pkg/META 55 | .merlin 56 | /node_modules/ 57 | -------------------------------------------------------------------------------- /website/static/css/custom.css: -------------------------------------------------------------------------------- 1 | hr { 2 | border: 0; 3 | height: 2px; 4 | background: #f9dfdf; 5 | margin: 30px 15px 40px 15px; 6 | } 7 | .hero { 8 | width: 100%; 9 | height: 460px; 10 | display: flex; 11 | flex-direction: column; 12 | align-items: center; 13 | justify-content: center; 14 | z-index: 0; 15 | } 16 | 17 | .quickStart { 18 | display: flex; 19 | flex-direction: column; 20 | align-items: center; 21 | justify-content: center; 22 | margin-bottom: 40px; 23 | } 24 | 25 | .quickStart h2 { 26 | font-weight: 200; 27 | font-size: 26px; 28 | } 29 | 30 | .paddedContainer { 31 | margin-left: 20px; 32 | margin-right: 20px; 33 | } 34 | 35 | nav.toc .toggleNav .navGroup.navGroupActive { 36 | background: #ffffff; 37 | color: #393939; 38 | } 39 | 40 | @media only screen and (min-device-width: 360px) and (max-device-width: 736px) { 41 | } 42 | 43 | @media only screen and (min-width: 1024px) { 44 | } 45 | 46 | @media only screen and (max-width: 1023px) { 47 | } 48 | 49 | @media only screen and (min-width: 1400px) { 50 | } 51 | 52 | @media only screen and (min-width: 1500px) { 53 | } 54 | -------------------------------------------------------------------------------- /website/i18n/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "_comment": "This file is auto-generated by write-translations.js", 3 | "localized-strings": { 4 | "next": "Next", 5 | "previous": "Previous", 6 | "tagline": "A Node.js-like API for ReasonML", 7 | "fs": "Fs", 8 | "Fs": "Fs", 9 | "installation": "Installation", 10 | "Installation": "Installation", 11 | "introExample": "Intro Example", 12 | "Intro Example": "Intro Example", 13 | "node": "Node", 14 | "Node": "Node", 15 | "path": "Path", 16 | "Path": "Path", 17 | "process": "Process", 18 | "Process": "Process", 19 | "whatWhy": "What & Why", 20 | "What & Why": "What & Why", 21 | "Docs": "Docs", 22 | "Help": "Help", 23 | "Blog": "Blog", 24 | "GitHub": "GitHub", 25 | "Getting Started": "Getting Started", 26 | "API": "API" 27 | }, 28 | "pages-strings": { 29 | "Help Translate|recruit community translators for your project": "Help Translate", 30 | "Edit this Doc|recruitment message asking to edit the doc source": "Edit", 31 | "Translate this Doc|recruitment message asking to translate the docs": "Translate" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Kennet Postigo 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 | -------------------------------------------------------------------------------- /website/crowdin.yaml: -------------------------------------------------------------------------------- 1 | project_identifier_env: CROWDIN_DOCUSAURUS_PROJECT_ID 2 | api_key_env: CROWDIN_DOCUSAURUS_API_KEY 3 | base_path: "./" 4 | preserve_hierarchy: true 5 | 6 | files: 7 | - 8 | source: '/docs/*.md' 9 | translation: '/website/translated_docs/%locale%/%original_file_name%' 10 | languages_mapping: &anchor 11 | locale: 12 | 'af': 'af' 13 | 'ar': 'ar' 14 | 'bs-BA': 'bs-BA' 15 | 'ca': 'ca' 16 | 'cs': 'cs' 17 | 'da': 'da' 18 | 'de': 'de' 19 | 'el': 'el' 20 | 'es-ES': 'es-ES' 21 | 'fa': 'fa-IR' 22 | 'fi': 'fi' 23 | 'fr': 'fr' 24 | 'he': 'he' 25 | 'hu': 'hu' 26 | 'id': 'id-ID' 27 | 'it': 'it' 28 | 'ja': 'ja' 29 | 'ko': 'ko' 30 | 'mr': 'mr-IN' 31 | 'nl': 'nl' 32 | 'no': 'no-NO' 33 | 'pl': 'pl' 34 | 'pt-BR': 'pt-BR' 35 | 'pt-PT': 'pt-PT' 36 | 'ro': 'ro' 37 | 'ru': 'ru' 38 | 'sk': 'sk-SK' 39 | 'sr': 'sr' 40 | 'sv-SE': 'sv-SE' 41 | 'tr': 'tr' 42 | 'uk': 'uk' 43 | 'vi': 'vi' 44 | 'zh-CN': 'zh-CN' 45 | 'zh-TW': 'zh-TW' 46 | 'en-UD': 'en-UD' 47 | - 48 | source: '/website/i18n/en.json' 49 | translation: '/website/i18n/%locale%.json' 50 | languages_mapping: *anchor -------------------------------------------------------------------------------- /website/pages/en/users.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | const React = require('react'); 9 | 10 | const CompLibrary = require('../../core/CompLibrary.js'); 11 | const Container = CompLibrary.Container; 12 | 13 | const siteConfig = require(process.cwd() + '/siteConfig.js'); 14 | 15 | class Users extends React.Component { 16 | render() { 17 | const showcase = siteConfig.users.map((user, i) => { 18 | return ( 19 | 20 | 21 | 22 | ); 23 | }); 24 | 25 | return ( 26 |
27 | 28 |
29 |
30 |

Who's Using This?

31 |

This project is used by many folks

32 |
33 |
{showcase}
34 |

Are you using this project?

35 | 38 | Add your company 39 | 40 |
41 |
42 |
43 | ); 44 | } 45 | } 46 | 47 | module.exports = Users; 48 | -------------------------------------------------------------------------------- /website/pages/en/help.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | const React = require('react'); 9 | 10 | const CompLibrary = require('../../core/CompLibrary.js'); 11 | const Container = CompLibrary.Container; 12 | const GridBlock = CompLibrary.GridBlock; 13 | 14 | const siteConfig = require(process.cwd() + '/siteConfig.js'); 15 | 16 | class Help extends React.Component { 17 | render() { 18 | const supportLinks = [ 19 | { 20 | content: 21 | 'Learn more using the [documentation on this site.](/test-site/docs/en/doc1.html)', 22 | title: 'Browse Docs', 23 | }, 24 | { 25 | content: 'Ask questions about the documentation and project', 26 | title: 'Join the community', 27 | }, 28 | { 29 | content: "Find out what's new with this project", 30 | title: 'Stay up to date', 31 | }, 32 | ]; 33 | 34 | return ( 35 |
36 | 37 |
38 |
39 |

Need help?

40 |
41 |

This project is maintained by a dedicated group of people.

42 | 43 |
44 |
45 |
46 | ); 47 | } 48 | } 49 | 50 | module.exports = Help; 51 | -------------------------------------------------------------------------------- /src/process.re: -------------------------------------------------------------------------------- 1 | let abort = (); 2 | 3 | let arch = (); 4 | 5 | let argv = Sys.argv; 6 | 7 | let argv0 = Sys.argv[0]; 8 | 9 | let channel = (); 10 | 11 | let chdir = directory => Sys.chdir(directory); 12 | 13 | let config = (); 14 | 15 | let connected = (); 16 | 17 | let cpuUsage = previousValue => (); 18 | 19 | let cwd = Sys.getcwd(); 20 | 21 | let disconnect = (); 22 | 23 | let emitWarning = (); 24 | 25 | let env = (); 26 | 27 | let execArgv = (); 28 | 29 | let execPath = (); 30 | 31 | let exitCode = ref(0); /* this should be set by user */ 32 | 33 | let exit = (~code=exitCode^) => exit(code); 34 | 35 | let getegid = () => Unix.getegid(); 36 | 37 | let geteuid = () => Unix.geteuid(); 38 | 39 | let getgid = Unix.getgid(); 40 | 41 | let getgroups = Unix.getgroups(); 42 | 43 | let getuid = Unix.getuid(); 44 | 45 | let hrtime = time => (); 46 | 47 | let initgroups = (~user, ~extraGroup) => Unix.initgroups(user, extraGroup); 48 | 49 | let kill = (~pid, ~signal) => Unix.kill(pid, signal); 50 | 51 | let mainModule = (); 52 | 53 | let memoryUsage = (); 54 | 55 | let nextTick = args => (); 56 | 57 | let pid = Unix.getpid(); 58 | 59 | let platform = (); 60 | 61 | let release = (); 62 | 63 | let send = (~message, ~sendHandle, ~options) => (); 64 | 65 | let setegid = id => (); 66 | 67 | let seteuid = id => (); 68 | 69 | let setgid = id => Unix.setgid(id); 70 | 71 | let setgroups = group => Unix.setgroups(group); 72 | 73 | let setuid = id => Unix.setuid(id); 74 | 75 | let stderr = (); 76 | 77 | let stdin = (); 78 | 79 | let stdout = (); 80 | 81 | let title = (); 82 | 83 | let unmask = mask => (); 84 | 85 | let uptime = () => (); 86 | 87 | let version = (); 88 | 89 | let versions = (); /* Exit codes */ -------------------------------------------------------------------------------- /website/siteConfig.js: -------------------------------------------------------------------------------- 1 | const resaurus = require("resaurus"); 2 | 3 | const users = [ 4 | { 5 | caption: "User1", 6 | image: "img/docusaurus.svg", 7 | infoLink: "https://www.facebook.com", 8 | pinned: true 9 | } 10 | ]; 11 | 12 | const siteConfig = { 13 | title: "lwt-node" /* title for your website */, 14 | tagline: "A Node.js-like API for ReasonML", 15 | url: "https://kennetpostigo.github.io/lwt-node" /* your website url */, 16 | editUrl: "https://github.com/kennetpostigo/lwt-node/tree/master/docs/", 17 | translationRecruitingLink: "https://crowdin.com/project/reason-node", 18 | baseUrl: "/lwt-node/" /* base url for your project */, 19 | organizationName: "kennetpostigo", 20 | projectName: "lwt-node", 21 | headerLinks: [ 22 | { doc: "whatWhy", label: "Docs" }, 23 | { page: "help", label: "Help" }, 24 | { blog: true, label: "Blog" }, 25 | { languages: true }, 26 | { search: true }, 27 | { 28 | href: "https://github.com/kennetpostigo/lwt-node", 29 | label: "GitHub" 30 | } 31 | ], 32 | users, 33 | /* path to images for header/footer */ 34 | headerIcon: "img/reasonNode.svg", 35 | footerIcon: "img/reasonNode.svg", 36 | favicon: "img/favicon.png", 37 | // This copyright info is used in /core/Footer.js and blog rss/atom feeds. 38 | copyright: "Copyright © " + new Date().getFullYear() + "Reason Training", 39 | // organizationName: 'deltice', // or set an env variable ORGANIZATION_NAME 40 | // projectName: 'test-site', // or set an env variable PROJECT_NAME 41 | scripts: ["https://buttons.github.io/buttons.js"], 42 | // You may provide arbitrary config keys to be used as needed by your template. 43 | repoUrl: "https://github.com/kennetpostigo/lwt-node", 44 | algolia: { 45 | apiKey: "e06120193f55f479c4ade444b75079a4", // This is temporary, sorry for copy and paste 46 | indexName: "reason-node" // This is temporary, sorry for copy and paste 47 | } 48 | }; 49 | 50 | module.exports = resaurus(siteConfig); 51 | -------------------------------------------------------------------------------- /docs/node.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: node 3 | title: Node 4 | sidebar_label: Node 5 | --- 6 | 7 | ### `Node.run` 8 | 9 | Starts the event loop for async/sync operations. 10 | 11 | #### Type definition 12 | 13 | ```reason 14 | let run: unit => unit; 15 | ``` 16 | 17 | #### Usage 18 | 19 | ```reason 20 | open LwtNode; 21 | 22 | Node.run({ 23 | let%lwt myDir = Fs.mkdir("myDir"); 24 | let%lwt myDir2 = Fs.mkdir("myDir2"); 25 | Node.resolved(); 26 | }); 27 | ``` 28 | 29 | --- 30 | 31 | ### `Node.stop` 32 | 33 | Stops the running event loop 34 | 35 | #### Type definition 36 | 37 | ```reason 38 | let stop: unit => unit; 39 | ``` 40 | 41 | #### Usage 42 | 43 | ```reason 44 | 45 | ``` 46 | 47 | --- 48 | 49 | ### `Node.andThen` 50 | 51 | Handle promise value 52 | 53 | #### Type definition 54 | 55 | ```reason 56 | let andThen: (t('a), 'a => t('b)) => t('b); 57 | ``` 58 | 59 | #### Usage 60 | 61 | ```reason 62 | 63 | ``` 64 | 65 | --- 66 | 67 | ### `Node.catch` 68 | 69 | Catch a promise that throws an exception 70 | 71 | #### Type definition 72 | 73 | ```reason 74 | let catch: (unit => t('a), exn => t('a)) => t('a); 75 | ``` 76 | 77 | #### Usage 78 | 79 | ```reason 80 | 81 | ``` 82 | 83 | --- 84 | 85 | ### `Node.resolved` 86 | 87 | Creates a resolved promise 88 | 89 | #### Type definition 90 | 91 | ```reason 92 | let resolved: 'a => t('a); 93 | ``` 94 | 95 | #### Usage 96 | 97 | ```reason 98 | 99 | ``` 100 | 101 | --- 102 | 103 | ### `Node.fail` 104 | 105 | Creates a rejected promise 106 | 107 | #### Type definition 108 | 109 | ```reason 110 | let fail: exn => t('a); 111 | ``` 112 | 113 | #### Usage 114 | 115 | ```reason 116 | 117 | ``` 118 | 119 | --- 120 | 121 | ### `Node.cancel` 122 | 123 | Canel a promise 124 | 125 | #### Type definition 126 | 127 | ```reason 128 | let cancel: t('a) => unit; 129 | ``` 130 | 131 | #### Usage 132 | 133 | ```reason 134 | 135 | ``` 136 | 137 | --- 138 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![lwt-node](website/static/img/readme.png) 2 | 3 |

4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

14 | 15 | lwt-node, a [reason](https://github.com/facebook/reason) implemention of the [node.js](https://github.com/nodejs/node) API. 16 | 17 | ## Install 18 | 19 | First you need to install [esy](https://github.com/esy/), Sandboxed and project based installations that share build artifacts and builds, for lightning fast installations and incremental builds: 20 | 21 | ```bash 22 | yarn global add esy 23 | 24 | # OR with npm 25 | 26 | npm install --global esy 27 | ``` 28 | 29 | Then go ahead and add lwt-node to your project with esy: 30 | 31 | ```bash 32 | esy add lwt-node 33 | ``` 34 | 35 | ## Usage 36 | 37 | See https://github.com/kennetpostigo/lwt-node-starter 38 | 39 | ## Documentation 40 | 41 | See https://kennetpostigo.github.io/lwt-node 42 | 43 | ## Contributing 44 | 45 | See [Contributing.md](https://github.com/kennetpostigo/lwt-node/blob/master/CONTRIBUTING.md) 46 | 47 | Missing or yet to be implemented API's are documented with compile-time warnings, are noted in the documentation and are listed in [Future.md](https://github.com/kennetpostigo/lwt-node/blob/master/Future.md). If you'd like to help contribute, please open a pull-request, no code needed! We'll try to help steer you in the right direction! 48 | 49 | **building** 50 | 51 | 1. Clone the project 52 | 2. Run `esy install` 53 | 3. Run `esy build` 54 | 55 | **testing** 56 | 57 | ``` 58 | esy make test 59 | ``` 60 | 61 | **Running commands** 62 | If you want to run commands that work directly on the project, you must always prefex them with 63 | `esy x` in order to run the command in the sandboxed environment. 64 | 65 | ## Attribution 66 | 67 | lwt-node would not be possible without all the hard work from the maintainers 68 | and contributors of of lwt. lwt-node is powered by lwt and the ocaml standard lib. 69 | Lwt provides a battle tested promise implementation and async operators. If you love lwt-node 70 | I recommend showing love to the [lwt project](https://github.com/ocsigen/lwt). 71 | 72 | ## License 73 | 74 | MIT 75 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ![](https://media.giphy.com/media/dzaUX7CAG0Ihi/giphy.gif) 4 | 5 | Hey! If you're here you probably want to help out! Thank you so much! Contributing to lwt-node can mean many things: 6 | 7 | * Ideas 8 | * Documentation additions or fixes 9 | * Questions 10 | * Finding Bugs 11 | * Helping with issues/answering questions 12 | * Code 13 | 14 | **To contribute code, there are a few options:** 15 | 16 | * Implement a function from [Future.md](https://github.com/kennetpostigo/lwt-node/blob/master/Future.md) that hasn't been implemented 17 | * Claim an issue that fixes a bug 18 | * Add tests for existing modules 19 | 20 | **Proposal** 21 | 22 | If you want to propose major changes to a module in lwt-node (Path, Fs, etc.) open an issue prefixed with [proposal] and try to be thorough in explaining: 23 | 24 | * Pain points with existing module 25 | * The major change you want to make 26 | * How making a major change would solve these pain points 27 | 28 | **Implementing more node.js modules** 29 | 30 | If you'd like to try your hand at adding other modules from node.js please open an issue, and let us know if you want to take lead in adding this module, as well as if you want to coordinate with others that might want to contribute. From there: 31 | 32 | * Open a Pull request with a checklist of work needed to be done 33 | * List who is working on what portions of the checklist 34 | * Include tests as much as possible for the new module you are adding. 35 | * Include corresponding interface file 36 | * Include Documentation for the new module 37 | 38 | ## Project Overview 39 | 40 | `lwt-node` for the most part is a wrapper around the stdlib for the sync portions and lwt for the async portions. However there are some missing portions that aren't accounted for (path, http, etc.) in the stdlib or lwt. In those cases they are implemented seperately. 41 | 42 | ## Building and testing from source 43 | 44 | **Install esy** 45 | 46 | ``` 47 | yarn global add esy@latest 48 | ``` 49 | 50 | **Install and build lwt-node** 51 | Within the lwt-node directory then run: 52 | 53 | ``` 54 | esy install 55 | 56 | esy build 57 | ``` 58 | 59 | **Run tests** 60 | 61 | ``` 62 | esy make test 63 | ``` 64 | 65 | **Running commands** 66 | If you want to run commands that work directly on the project, you must always prefex them with 67 | `esy x` in order to run the command in the sandboxed environment. 68 | 69 | ### Thank you 70 | 71 | If you've gotten here and you still want to contribute, thank you so much! Giving your time to help a project is no small sacrifice and we are thankful for all the time you put forth in making this project better. 72 | -------------------------------------------------------------------------------- /website/static/img/reasonNode.svg: -------------------------------------------------------------------------------- 1 | 2 | text and rect 3 | Created using Figma 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /website/static/img/reasonNodePrimary.svg: -------------------------------------------------------------------------------- 1 | 2 | text and rect 3 | Created using Figma 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /website/blog/2017-12-31-initial-release.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Initial Release 3 | author: Kennet Postigo 4 | authorURL: http://twitter.com/kennetpostigo 5 | authorFBID: 1370308025 6 | --- 7 | 8 | ![](/lwt-node/img/slash-introducing.png) 9 | 10 | I am very happy to introduce [lwt-node](https://github.com/kennetpostigo/lwt-node) to help make native programming in reason easy and familiar. 11 | 12 | I created lwt-node for the following reasons: 13 | 14 | 1. Provide a way for reason developers to create native projects by emulating the node.js API that has been proven to be easy and intuitive. 15 | 2. Performance is priceless, while there are [bucklescript bindings to node.js](https://github.com/reasonml-community/bs-node) you will still have to pay for the node.js startup and execution cost. `lwt-node` stays closer to the metal thanks to ocaml-opt. 16 | 3. OCaml stdlib and other libraries organized modules in a manner that was difficult to find what I was looking for. 17 | 4. Lastly, I really loved node.js API and have used it for several years, and i'm sure many others that are moving from javascript to reason would appreciate being able to translate over some of their node.js knowledge base. 18 | 19 | It's very early for `lwt-node` and much of `fs` and `process` API still needs to be fleshed out, so I'm hoping to get more of it out in the coming weeks/months, hopefully with the help of some contributors! Much of the next work is adding more tests for existing modules and including an HTTP module. If you are interested in contributing in any way shape or form, take a read of our [contributing document](https://github.com/kennetpostigo/lwt-node/blob/master/CONTRIBUTING.md). 20 | 21 | `lwt-node` has a strong value proposition for teams at companies that have adopted [reason](reasonml.github.io) and use [node.js](nodejs.org) – you get to keep the familiar node.js API, drop the start-up costs, gain a great type-system, and take advantage ocaml-opts performance. To make things better, organizing functions in the same manner as node.js does (path, fs, http, etc.) make it easier to find what you are looking for compared to the stdlib and hopefully we can provide prettier, clearer documentation with examples. 22 | 23 | ### How Does it work? 24 | 25 | `lwt-node` for the most part is a wrapper around the stdlib for the sync portions and lwt for the async portions. However there are some missing portions that aren't accounted for (path, http, etc.) in the stdlib or lwt. In those cases they are implemented seperately. 26 | 27 | ### Getting up and running 28 | 29 | It's simple and fast to hit the ground running: 30 | 31 | 1. Check out the [installation instructions](https://kennetpostigo.github.io/lwt-node/docs/installation.html) 32 | 2. clone the [starter project](https://github.com/kennetpostigo/lwt-node-starter) 33 | 34 | ### Final Remarks 35 | 36 | I hope people will try it out, add a comment [here](https://github.com/kennetpostigo/lwt-node/issues/new) if you try it out and dislike a specific part of it or just completely hate it. If you're reading this and aren't familiar with reason, you should really check it out! 37 | 38 | * [Reason](https://reasonml.github.io/) 39 | * Oh and theres react [ReasonReact](https://reasonml.github.io/reason-react) 40 | -------------------------------------------------------------------------------- /website/languages.js: -------------------------------------------------------------------------------- 1 | const languages = [ 2 | { 3 | enabled: false, 4 | name: "日本語", 5 | tag: "ja" 6 | }, 7 | { 8 | enabled: true, 9 | name: "English", 10 | tag: "en" 11 | }, 12 | { 13 | enabled: false, 14 | name: "العربية", 15 | tag: "ar" 16 | }, 17 | { 18 | enabled: false, 19 | name: "Bosanski", 20 | tag: "bs-BA" 21 | }, 22 | { 23 | enabled: false, 24 | name: "Català", 25 | tag: "ca" 26 | }, 27 | { 28 | enabled: false, 29 | name: "Čeština", 30 | tag: "cs" 31 | }, 32 | { 33 | enabled: false, 34 | name: "Dansk", 35 | tag: "da" 36 | }, 37 | { 38 | enabled: false, 39 | name: "Deutsch", 40 | tag: "de" 41 | }, 42 | { 43 | enabled: false, 44 | name: "Ελληνικά", 45 | tag: "el" 46 | }, 47 | { 48 | enabled: false, 49 | name: "Español", 50 | tag: "es-ES" 51 | }, 52 | { 53 | enabled: false, 54 | name: "فارسی", 55 | tag: "fa-IR" 56 | }, 57 | { 58 | enabled: false, 59 | name: "Suomi", 60 | tag: "fi" 61 | }, 62 | { 63 | enabled: true, 64 | name: "Français", 65 | tag: "fr" 66 | }, 67 | { 68 | enabled: false, 69 | name: "עִברִית", 70 | tag: "he" 71 | }, 72 | { 73 | enabled: false, 74 | name: "Magyar", 75 | tag: "hu" 76 | }, 77 | { 78 | enabled: false, 79 | name: "Bahasa Indonesia", 80 | tag: "id-ID" 81 | }, 82 | { 83 | enabled: false, 84 | name: "Italiano", 85 | tag: "it" 86 | }, 87 | { 88 | enabled: false, 89 | name: "Afrikaans", 90 | tag: "af" 91 | }, 92 | { 93 | enabled: false, 94 | name: "한국어", 95 | tag: "ko" 96 | }, 97 | { 98 | enabled: false, 99 | name: "मराठी", 100 | tag: "mr-IN" 101 | }, 102 | { 103 | enabled: false, 104 | name: "Nederlands", 105 | tag: "nl" 106 | }, 107 | { 108 | enabled: false, 109 | name: "Norsk", 110 | tag: "no-NO" 111 | }, 112 | { 113 | enabled: false, 114 | name: "Polskie", 115 | tag: "pl" 116 | }, 117 | { 118 | enabled: false, 119 | name: "Português", 120 | tag: "pt-PT" 121 | }, 122 | { 123 | enabled: false, 124 | name: "Português (Brasil)", 125 | tag: "pt-BR" 126 | }, 127 | { 128 | enabled: false, 129 | name: "Română", 130 | tag: "ro" 131 | }, 132 | { 133 | enabled: true, 134 | name: "Русский", 135 | tag: "ru" 136 | }, 137 | { 138 | enabled: false, 139 | name: "Slovenský", 140 | tag: "sk-SK" 141 | }, 142 | { 143 | enabled: false, 144 | name: "Српски језик (Ћирилица)", 145 | tag: "sr" 146 | }, 147 | { 148 | enabled: false, 149 | name: "Svenska", 150 | tag: "sv-SE" 151 | }, 152 | { 153 | enabled: false, 154 | name: "Türkçe", 155 | tag: "tr" 156 | }, 157 | { 158 | enabled: false, 159 | name: "Українська", 160 | tag: "uk" 161 | }, 162 | { 163 | enabled: false, 164 | name: "Tiếng Việt", 165 | tag: "vi" 166 | }, 167 | { 168 | enabled: true, 169 | name: "中文", 170 | tag: "zh-CN" 171 | }, 172 | { 173 | enabled: false, 174 | name: "繁體中文", 175 | tag: "zh-Hant" 176 | }, 177 | { 178 | enabled: false, 179 | name: "ɥsᴉlƃuƎ uʍopǝpᴉsd∩", 180 | tag: "en-UD" 181 | } 182 | ]; 183 | 184 | module.exports = languages; 185 | -------------------------------------------------------------------------------- /website/static/nodes.js: -------------------------------------------------------------------------------- 1 | function run() { 2 | var width = window.innerWidth; 3 | var height = 460; 4 | var elm = document.createElement("canvas"); 5 | var pixelDensity = window.devicePixelRatio || 1; 6 | var orbs = []; 7 | var orbCount = 30; 8 | elm.setAttribute("id", "cvas"); 9 | elm.setAttribute("width", width * pixelDensity); 10 | elm.setAttribute("height", height * pixelDensity); 11 | 12 | elm.style["z-index"] = 100; 13 | elm.style.width = width + "px"; 14 | elm.style.height = height + "px"; 15 | elm.style.position = "absolute"; 16 | 17 | var ctx = elm.getContext("2d"); 18 | 19 | document.body.prepend(elm); 20 | 21 | function generateOrbs() { 22 | orbs = []; 23 | let i = 0; 24 | while (i < orbCount) { 25 | orbs[i] = new orb(); 26 | ++i; 27 | } 28 | } 29 | 30 | window.addEventListener("resize", resize); 31 | 32 | function resize() { 33 | width = window.innerWidth; 34 | elm.setAttribute("width", width * pixelDensity); 35 | elm.style.width = width + "px"; 36 | } 37 | 38 | function generateConnection(i) { 39 | var connectTo = ~~(Math.random() * orbs.length); 40 | if (orbs[i].connections.indexOf(orbs[connectTo]) !== -1) { 41 | generateConnection(i); 42 | } else { 43 | orbs[i].connections.push(orbs[connectTo]); 44 | } 45 | } 46 | 47 | function generateOrbConnections() { 48 | for (let i = 0; i < orbs.length; ++i) { 49 | generateConnection(i); 50 | } 51 | } 52 | 53 | function orb() { 54 | this.radius = 15; 55 | this.connections = []; 56 | this.color = ["rgba(255,255,255, 0.7)"]; 57 | this.x = ~~(Math.random() * (elm.width - this.radius) + this.radius); 58 | this.y = ~~(Math.random() * (elm.height - this.radius) + this.radius); 59 | this.xVelocity = 60 | ~~(Math.random() * 5) * (~~(Math.random() * 2) === 0 ? -1 : 1); 61 | this.yVelocity = 62 | ~~(Math.random() * 2) * (~~(Math.random() * 2) === 0 ? -1 : 1); 63 | 64 | return this; 65 | } 66 | 67 | orb.prototype.draw = function() { 68 | ctx.fillStyle = this.color; 69 | ctx.strokeStyle = this.color; 70 | 71 | ctx.beginPath(); 72 | ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2, 1); 73 | ctx.fill(); 74 | ctx.closePath(); 75 | for (var i = 0; i < this.connections.length; ++i) { 76 | ctx.beginPath(); 77 | ctx.moveTo(this.x, this.y); 78 | ctx.lineTo(this.connections[i].x, this.connections[i].y); 79 | ctx.stroke(); 80 | ctx.closePath(); 81 | } 82 | }; 83 | 84 | orb.prototype.move = function() { 85 | if ( 86 | this.x + this.xVelocity + this.radius >= elm.width || 87 | this.x + this.xVelocity <= 0 88 | ) { 89 | this.xVelocity && (this.xVelocity -= Math.random() * 2); 90 | this.xVelocity *= -1; 91 | } 92 | if ( 93 | this.y + this.yVelocity < 0 || 94 | this.y + this.yVelocity + this.radius >= elm.height 95 | ) { 96 | this.xVelocity && (this.yVelocity -= Math.random() * 2); 97 | 98 | this.yVelocity *= -1; 99 | } 100 | 101 | this.x += this.xVelocity; 102 | this.y += this.yVelocity; 103 | this.draw(); 104 | }; 105 | 106 | function tick() { 107 | window.requestAnimationFrame(tick); 108 | ctx.clearRect(0, 0, elm.width, elm.height); 109 | for (var i = 0; i < orbs.length; ++i) { 110 | orbs[i].move(); 111 | } 112 | } 113 | 114 | generateOrbs(); 115 | generateOrbConnections(); 116 | tick(); 117 | } 118 | 119 | console.log("shit"); 120 | run(); 121 | console.log("done shit"); 122 | -------------------------------------------------------------------------------- /src/fs.re: -------------------------------------------------------------------------------- 1 | type asyncFileDescr = Lwt_unix.file_descr; 2 | 3 | type syncFileDescr = Unix.file_descr; 4 | 5 | type asyncFilePerm = Lwt_unix.file_perm; 6 | 7 | type syncFilePerm = Unix.file_perm; 8 | 9 | type accessPermission = Unix.access_permission = | R_OK | W_OK | X_OK | F_OK; 10 | 11 | type asyncStats = Lwt_unix.stats; 12 | 13 | type syncStats = Unix.stats; 14 | 15 | type asyncDirHandle = Lwt_unix.dir_handle; 16 | 17 | type syncDirHandle = Unix.dir_handle; 18 | 19 | type asyncOpenFlag = Lwt_unix.open_flag; 20 | 21 | type syncOpenFlag = Unix.open_flag; 22 | 23 | let access = (~mode=F_OK, path) => Lwt_unix.access(path, [mode]); 24 | 25 | let accessSync = (~mode=F_OK, path) => Unix.access(path, [mode]); 26 | 27 | let appendFile = (~file, ~data, ~options) => (); 28 | 29 | let appendFileSync = (~file, ~data, ~options) => (); 30 | 31 | let chmod = (~path, ~mode) => Lwt_unix.chmod(path, mode); 32 | 33 | let chmodSync = (~path, ~mode) => Unix.chmod(path, mode); 34 | 35 | let chown = (~path, ~uid, ~gid) => Lwt_unix.chown(path, uid, gid); 36 | 37 | let chownSync = (~path, ~uid, ~gid) => Unix.chown(path, uid, gid); 38 | 39 | let close = fd => Lwt_unix.close(fd); 40 | 41 | let closeSync = fd => Unix.close(fd); 42 | 43 | let createReadStream = (~path, ~options) => (); 44 | 45 | let createWriteStream = (~path, ~options) => (); 46 | 47 | let fchmod = (~fd, ~mode) => Lwt_unix.fchmod(fd, mode); 48 | 49 | let fchmodSync = (~fd, ~mode) => Unix.fchmod(fd, mode); 50 | 51 | let fchown = (~fd, ~uid, ~gid) => Lwt_unix.fchown(fd, uid, gid); 52 | 53 | let fchownSync = (~fd, ~uid, ~gid) => Unix.fchown(fd, uid, gid); 54 | 55 | let fdatasync = fd => Lwt_unix.fdatasync(fd); 56 | 57 | let fdatasyncSync = fd => (); 58 | 59 | let fstat = fd => Lwt_unix.fstat(fd); 60 | 61 | let fstatSync = fd => Unix.fstat(fd); 62 | 63 | let fsync = fd => Lwt_unix.fsync(fd); 64 | 65 | let fsyncSync = fd => (); 66 | 67 | let ftruncate = (~len=0, fd) => Lwt_unix.ftruncate(fd, len); 68 | 69 | let ftruncateSync = (~len=0, fd) => Unix.ftruncate(fd, len); 70 | 71 | let futimes = (~fd, ~atime, ~mtime) => (); 72 | 73 | let futimesSync = (~fd, ~atime, ~mtime) => (); 74 | 75 | let lchmod = (~path, ~mode) => (); 76 | 77 | let lchmodSync = (~path, ~mode) => (); 78 | 79 | let lchown = (~path, ~uid, ~gid) => (); 80 | 81 | let lchownSync = (~path, ~uid, ~gid) => (); 82 | 83 | let link = (~existingPath, ~newPath) => Lwt_unix.link(existingPath, newPath); 84 | 85 | let linkSync = (~existingPath, ~newPath) => Unix.link(existingPath, newPath); 86 | 87 | let lstat = path => Lwt_unix.lstat(path); 88 | 89 | let lstatSync = path => Unix.lstat(path); 90 | 91 | let mkdir = (~mode=511, path) => Lwt_unix.mkdir(path, mode); 92 | 93 | let mkdirSync = (~mode=511, path) => Unix.mkdir(path, mode); 94 | 95 | let mkdtemp = (~prefix, ~options) => (); 96 | 97 | let mkdtempSync = (~prefix, ~options) => (); 98 | 99 | let _open = (~flags, ~mode=438, path) => Lwt_unix.openfile(path, flags, mode); 100 | 101 | let openSync = (~flags, ~mode=438, path) => Unix.openfile(path, flags, mode); 102 | 103 | let read = (~fd, ~buffer, ~offset, ~length) => 104 | Lwt_unix.read(fd, buffer, offset, length); 105 | 106 | let readSync = (~fd, ~buffer, ~offset, ~length) => 107 | Unix.read(fd, buffer, offset, length); 108 | 109 | let readdir = path => Lwt_unix.readdir(path); 110 | 111 | let readdirSync = path => Unix.readdir(path); 112 | 113 | let readFile = (~path, ~options) => (); 114 | 115 | let readFileSync = (~path, ~options) => (); 116 | 117 | let readLink = path => Lwt_unix.readlink(path); 118 | 119 | let readLinkSync = path => Unix.readlink(path); 120 | 121 | let realpath = (~path, ~options) => (); 122 | 123 | let realpathSync = (~path, ~options) => (); 124 | 125 | let rename = (~oldPath, ~newPath) => Lwt_unix.rename(oldPath, newPath); 126 | 127 | let renameSync = (~oldPath, ~newPath) => Unix.rename(oldPath, newPath); 128 | 129 | let rmdir = path => Lwt_unix.rmdir(path); 130 | 131 | let rmdirSync = path => Unix.rmdir(path); 132 | 133 | let stat = path => Lwt_unix.stat(path); 134 | 135 | let statSync = path => Unix.stat(path); 136 | 137 | let symlink = (~target, ~path) => Lwt_unix.symlink(target, path); 138 | 139 | let symlinkSync = (~target, ~path) => Unix.symlink(target, path); 140 | 141 | let truncate = (~len=0, path) => Lwt_unix.truncate(path, len); 142 | 143 | let truncateSync = (~len=0, path) => Unix.truncate(path, len); 144 | 145 | let unlink = path => Lwt_unix.unlink(path); 146 | 147 | let unlinkSync = path => Unix.unlink(path); 148 | 149 | let unwatchFile = (~filename, ~listener) => (); 150 | 151 | let utimes = (~path, ~atime, ~mtime) => Lwt_unix.utimes(path, atime, mtime); 152 | 153 | let utimesSync = (~path, ~atime, ~mtime) => Unix.utimes(path, atime, mtime); 154 | 155 | let watch = (~filename, ~options, ~listener) => (); 156 | 157 | let watchFile = (~filename, ~options, ~listener) => (); 158 | 159 | let write = (~fd, ~buffer, ~offset, ~length) => 160 | Lwt_unix.write(fd, buffer, offset, length); 161 | 162 | let writeSync = (~fd, ~buffer, ~offset, ~length) => 163 | Unix.write(fd, buffer, offset, length); 164 | 165 | let writeString = (~fd, ~string, ~offset, ~length) => 166 | Lwt_unix.write_string(fd, string, offset, length); 167 | 168 | let writeStringSync = (~fd, ~string, ~offset, ~length) => 169 | Unix.write_substring(fd, string, offset, length); 170 | 171 | let writeFile = (~file, ~data, ~options) => (); 172 | 173 | let writeFileSync = (~file, ~data, ~options) => (); -------------------------------------------------------------------------------- /website/pages/en/index.js: -------------------------------------------------------------------------------- 1 | const React = require("react"); 2 | 3 | const CompLibrary = require("../../core/CompLibrary.js"); 4 | const MarkdownBlock = CompLibrary.MarkdownBlock; /* Used to read markdown */ 5 | const Container = CompLibrary.Container; 6 | const GridBlock = CompLibrary.GridBlock; 7 | const siteConfig = require(process.cwd() + "/siteConfig.js"); 8 | 9 | function imgUrl(img) { 10 | return siteConfig.baseUrl + "img/" + img; 11 | } 12 | 13 | function docUrl(doc, language) { 14 | return siteConfig.baseUrl + "docs/" + (language ? language + "/" : "") + doc; 15 | } 16 | 17 | function pageUrl(page, language) { 18 | return siteConfig.baseUrl + (language ? language + "/" : "") + page; 19 | } 20 | 21 | class Button extends React.Component { 22 | render() { 23 | return ( 24 |
25 | 26 | {this.props.children} 27 | 28 |
29 | ); 30 | } 31 | } 32 | 33 | Button.defaultProps = { 34 | target: "_self" 35 | }; 36 | 37 | const SplashContainer = props => ( 38 |
39 |
40 |
{props.children}
41 |
42 |
43 | ); 44 | 45 | const Logo = props => ( 46 |
47 | 48 |
49 | ); 50 | 51 | const ProjectTitle = props => ( 52 |

53 | {siteConfig.title} 54 | {siteConfig.tagline} 55 |

56 | ); 57 | 58 | const PromoSection = props => ( 59 |
60 |
61 |
{props.children}
62 |
63 |
64 | ); 65 | 66 | class HomeSplash extends React.Component { 67 | render() { 68 | let language = this.props.language || ""; 69 | return ( 70 | 71 | 72 |
73 |

74 | {siteConfig.tagline} 75 |

76 | 77 | 78 | 79 |
80 |
81 | ); 82 | } 83 | } 84 | 85 | const Block = props => ( 86 | 91 | 92 | 93 | ); 94 | 95 | const Features = props => ( 96 | 97 | {[ 98 | { 99 | content: 100 | "Reason runs in the native environment, ocaml-opt provides blazing fast startup and execution.", 101 | imageAlign: "top", 102 | title: "Native Performance" 103 | }, 104 | { 105 | content: 106 | "The same Node.js API that you know and love, get started painlessly!", 107 | imageAlign: "top", 108 | title: "Familiar API" 109 | }, 110 | { 111 | content: 112 | "Reason provides a nice and fun type system, making writing and refactoring your code easy and fun!", 113 | imageAlign: "top", 114 | title: "Fun Types" 115 | } 116 | ]} 117 | 118 | ); 119 | 120 | const pre = "```"; 121 | const code = "`"; 122 | 123 | const codeExample = `${pre}reason 124 | open LwtNode; 125 | 126 | Node.run({ 127 | let%lwt myDir = Fs.mkdir("myDir"); 128 | let%lwt myDir2 = Fs.mkdir("myDir2"); 129 | Node.resolved(); 130 | }); 131 | ${pre}`; 132 | 133 | const QuickStart = props => ( 134 |
135 |
136 |

Quick Start

137 | {codeExample} 138 |
139 |
140 | ); 141 | 142 | const Showcase = props => { 143 | if ((siteConfig.users || []).length === 0) { 144 | return null; 145 | } 146 | const showcase = siteConfig.users 147 | .filter(user => { 148 | return user.pinned; 149 | }) 150 | .map((user, i) => { 151 | return ( 152 | 153 | 154 | 155 | ); 156 | }); 157 | 158 | return ( 159 |
160 |

{"Who's Using This?"}

161 |

This project is used by all these people

162 |
{showcase}
163 |
164 | 165 | More {siteConfig.title} Users 166 | 167 |
168 |
169 | ); 170 | }; 171 | 172 | class Index extends React.Component { 173 | componentDidMount() { 174 | nodes(); 175 | } 176 | 177 | componentWillUnmount() { 178 | document.body.removeChild(document.getElementById("cvas")); 179 | } 180 | render() { 181 | let language = this.props.language || ""; 182 | 183 | return ( 184 |
185 | {/*