Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hive-js
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
hive-js
Commits
986cd8fb
Commit
986cd8fb
authored
8 years ago
by
yamadapc
Browse files
Options
Downloads
Patches
Plain Diff
Generate methods from the definition
parent
a092d82e
No related branches found
No related tags found
No related merge requests found
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/api-from-methods.js
+36
-35
36 additions, 35 deletions
lib/api-from-methods.js
lib/api.js
+108
-1063
108 additions, 1063 deletions
lib/api.js
package.json
+1
-1
1 addition, 1 deletion
package.json
with
145 additions
and
1099 deletions
lib/api-from-methods.js
+
36
−
35
View file @
986cd8fb
var
Steem
=
require
(
'
./api
'
);
var
methods
=
require
(
'
./methods.json
'
);
var
methods
=
require
(
'
./methods.json
'
);
var
snakeCaseRe
=
/_
([
a-z
])
/g
var
snakeCaseRe
=
/_
([
a-z
])
/g
...
@@ -8,40 +7,42 @@ function camelCase(str) {
...
@@ -8,40 +7,42 @@ function camelCase(str) {
});
});
}
}
exports
=
module
.
exports
=
methods
.
reduce
(
function
(
memo
,
method
)
{
exports
=
module
.
exports
=
function
generateMethods
(
Steem
)
{
var
methodName
=
camelCase
(
method
.
method
);
methods
.
reduce
(
function
(
memo
,
method
)
{
var
methodName
=
camelCase
(
method
.
method
);
memo
[
methodName
+
'
With
'
]
=
function
Steem$specializedSendWith
(
options
,
callback
)
{
memo
[
methodName
+
'
With
'
]
=
var
params
=
method
.
params
.
map
(
function
(
param
)
{
function
Steem$specializedSendWith
(
options
,
callback
)
{
return
options
[
param
];
var
params
=
method
.
params
.
map
(
function
(
param
)
{
});
return
options
[
param
];
var
iterator
=
Steem
.
iterate
();
});
var
iterator
=
Steem
.
iterate
();
return
Steem
.
send
(
method
.
api
,
{
id
:
iterator
,
return
Steem
.
send
(
method
.
api
,
{
method
:
method
.
method
,
id
:
iterator
,
params
:
params
,
method
:
method
.
method
,
},
function
(
err
,
data
)
{
params
:
params
,
if
(
err
)
return
callback
(
err
);
},
function
(
err
,
data
)
{
if
(
data
&&
data
.
id
===
iterator
)
return
callback
(
err
,
data
.
result
);
if
(
err
)
return
callback
(
err
);
// TODO - Do something here
if
(
data
&&
data
.
id
===
iterator
)
return
callback
(
err
,
data
.
result
);
});
// TODO - Do something here
};
});
};
memo
[
methodName
]
=
function
Steem$specializedSend
()
{
memo
[
methodName
]
=
var
args
=
arguments
;
function
Steem$specializedSend
()
{
var
options
=
method
.
params
.
reduce
(
function
(
memo
,
param
,
i
)
{
var
args
=
arguments
;
memo
[
param
]
=
args
[
i
];
var
options
=
method
.
params
.
reduce
(
function
(
memo
,
param
,
i
)
{
return
memo
;
memo
[
param
]
=
args
[
i
];
},
{});
return
memo
;
var
callback
=
args
[
method
.
params
.
length
];
},
{});
memo
[
methodName
+
'
With
'
](
options
,
callback
);
var
callback
=
args
[
method
.
params
.
length
];
};
memo
[
methodName
+
'
With
'
](
options
,
callback
);
};
return
memo
;
},
{});
return
memo
;
},
Steem
);
};
/*
/*
...
...
This diff is collapsed.
Click to expand it.
lib/api.js
+
108
−
1063
View file @
986cd8fb
This diff is collapsed.
Click to expand it.
package.json
+
1
−
1
View file @
986cd8fb
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
"description"
:
"Steem.js the JavaScript API for Steem blockchain"
,
"description"
:
"Steem.js the JavaScript API for Steem blockchain"
,
"main"
:
"index.js"
,
"main"
:
"index.js"
,
"scripts"
:
{
"scripts"
:
{
"test"
:
"
node test.js
"
,
"test"
:
"
mocha --require babel-register
"
,
"build"
:
"browserify lib/browser.js -o examples/steem.js && uglifyjs examples/steem.js -o examples/steem.min.js && uglifyjs examples/steem.js -o steem.min.js"
"build"
:
"browserify lib/browser.js -o examples/steem.js && uglifyjs examples/steem.js -o examples/steem.min.js && uglifyjs examples/steem.js -o steem.min.js"
},
},
"browser"
:
{
"browser"
:
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment