Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async/Await #248

Merged
merged 19 commits into from
Jun 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"presets": [
["env", {
"targets": {
"browsers": ["last 2 versions"],
"node": "6"
}
}]
]
}
6 changes: 5 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.coffee,*.md]
[*.coffee]
indent_style = space
indent_size = 2

[*.md]
indent_style = space
indent_size = 2
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
lib/
lib.es6/
dist/
node_modules/
.idea/
test.babel/

#OS X
.DS_Store
.DS_Store
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
language: node_js
node_js:
- "node"
- "8"
- "7"
- "6"
- "5"
- "4"
- "0.12"
- "iojs"
before_install:
- npm install -g grunt-cli coffee-script
script: grunt test
- npm install -g babel-cli webpack uglify-js nodeunit
script: npm run test
87 changes: 41 additions & 46 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,16 @@ $ git clone [email protected]:your-username/rivescript-js.git
Make sure you have `node` and `npm` and set up the build dependencies:

```bash
$ npm install -g grunt-cli # If you don't already have it
$ npm install # Install dev dependencies
```
# CLI dependencies if you don't have them already
$ npm install -g babel-cli webpack uglify-js nodeunit

Make your code changes in `rivescript.js` and test them either by using the
TCP example server in `node/tcp-server.js` or by using the built-in web server
by running `grunt connect:server`.
# Install dev dependencies for rivescript-js
$ npm install
```

Make sure the unit tests still pass (`grunt test`), and add new unit tests if
Make sure the unit tests still pass (`npm run test`), and add new unit tests if
necessary for your change.

Run JS linting with `grunt lint` and fix any issues that occur.

When finished, run `grunt` to create the minified JS file.

Push to your fork and [submit a pull request](https://github.com/aichaos/rivescript-js/compare/).

At this point you're waiting on me. I'm usually pretty quick to comment on pull
Expand All @@ -46,50 +41,50 @@ Some things that will increase the chance that your pull request is accepted:

# Code Documentation Style

For this project I've adopted a JavaDoc-style documentation system for the CoffeeScript source code. Look at existing function documentation for examples, but briefly:
For this project I've adopted a JavaDoc-style documentation system in the source
code. Look at existing function documentation for examples, but briefly:

* Begin the comment block with two comment characters: `##`
* Each line of the comment block should begin with a `#` symbol.
* Begin the comment block like: `/**`
* Do NOT use a `*` as a prefix for each line.
* The comment block should begin with the function definition prototype (use Java style data types to denote what each parameter should be)
* Use a blank line between the function prototype and the description.
* Use [Markdown syntax](http://daringfireball.net/projects/markdown/syntax) - the documentation is generated as Markdown files and then rendered to HTML.
* End the comment block with another pair of `##` symbols.
* End the comment block with a `*/` sequence.
* There should be no more comments touching the comment block (if you need a comment directly after the comment block, leave a blank line in between, or else that comment may end up becoming a part of the documentation!)

Examples:

```coffeescript
##
# string processTags (string user, string msg, string reply, string[] stars,
# string[] botstars, int step, scope)
#
# Process tags in a reply element.
##
processTags: (user, msg, reply, st, bst, step, scope) ->

```javascript
/**
string processTags (string user, string msg, string reply, string[] stars,
string[] botstars, int step, scope)

Process tags in a reply element.
*/
processTags: (user, msg, reply, st, bst, step, scope) => {}
...
##
# int loadFile (string path || array path[, onSuccess[, onError]])
#
# Load a RiveScript document from a file. The path can either be a string that
# contains the path to a single file, or an array of paths to load multiple
# files. `onSuccess` is a function to be called when the file(s) have been
# successfully loaded. `onError` is for catching any errors, such as syntax
# errors.
#
# This loading method is asynchronous. You should define an `onSuccess`
# handler to be called when the file(s) have been successfully loaded.
#
# This method returns a "batch number" for this load attempt. The first call
# to this function will have the batch number of 0 and that will go up from
# there. This batch number is passed to your `onSuccess` handler as its only
# argument, in case you want to correlate it with your call to `loadFile()`.
#
# `onSuccess` receives: int batchNumber
# `onError` receives: string errorMessage[, int batchNumber]
##
loadFile: (path, onSuccess, onError) ->

/**
int loadFile (string path || array path[, onSuccess[, onError]])

Load a RiveScript document from a file. The path can either be a string that
contains the path to a single file, or an array of paths to load multiple
files. `onSuccess` is a function to be called when the file(s) have been
successfully loaded. `onError` is for catching any errors, such as syntax
errors.

This loading method is asynchronous. You should define an `onSuccess`
handler to be called when the file(s) have been successfully loaded.

This method returns a "batch number" for this load attempt. The first call
to this function will have the batch number of 0 and that will go up from
there. This batch number is passed to your `onSuccess` handler as its only
argument, in case you want to correlate it with your call to `loadFile()`.

`onSuccess` receives: int batchNumber
`onError` receives: string errorMessage[, int batchNumber]
*/
loadFile: (path, onSuccess, onError) => {}
```

To compile the documentation, you'll need Python and the `markdown` module installed. If you can't do this, don't worry too much about it; the project maintainer will rebuild the documentation periodically. Quick start:
Expand Down
Loading