Skip to content

Commit

Permalink
remove async option from soct
Browse files Browse the repository at this point in the history
  • Loading branch information
jhenson29 committed Nov 20, 2018
1 parent 49fa209 commit 7bfbebc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ npm i -s soct
```

## Getting Started
### Class to proxy.
### Class to proxy
```javascript
// foo.js

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "soct",
"version": "1.0.1",
"version": "1.0.2",
"description": "Proxy classes over socket.io.",
"main": "./src/index.js",
"scripts": {
Expand Down
8 changes: 3 additions & 5 deletions src/soct/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const _emit = Symbol('emit');

const OPTIONDEFAULT = {
host: 'http://localhost',
async: false,
};

/**
Expand All @@ -21,7 +20,6 @@ class Soct{
port,
{
host = OPTIONDEFAULT.host,
async = OPTIONDEFAULT.async,
} = OPTIONDEFAULT
){
this[_socket] = require('socket.io-client')(`${host}:${port}`);
Expand All @@ -30,16 +28,16 @@ class Soct{

// map a method
if (typeof testObj[prop] === 'function')
this[prop] = async (...args) => async ? this[_emit](prop,[...args]) : await this[_emit](prop,[...args]);
this[prop] = async (...args) => this[_emit](prop,[...args]);

// map a property
else {
Object.defineProperty(
this,
prop,
{
get: async () => async ? this[_emit](prop) : await this[_emit](prop),
set: async args => async ? this[_emit](prop,args) : await this[_emit](prop, args)
get: () => this[_emit](prop),
set: args => this[_emit](prop,args)
}
);
}
Expand Down

0 comments on commit 7bfbebc

Please sign in to comment.