Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcf55d41

Browse files
committed
Merge pull requestmarianoguerra#24 from nickyout/nodejs-support
Nodejs support
2 parents933402d +e60c20f commitcf55d41

File tree

4 files changed

+39
-4
lines changed

4 files changed

+39
-4
lines changed

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

‎lib/crel.js‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@
3636

3737
(function(root,factory){
3838
if(typeofexports==='object'){
39-
module.exports=factory();
39+
if(!root.window){
40+
varjsdom=require('jsdom').jsdom;
41+
root.window=jsdom().parentWindow;
42+
}
43+
module.exports=factory(root.window);
4044
}elseif(typeofdefine==='function'&&define.amd){
41-
define(factory);
45+
define(factory.bind(null,window));
4246
}else{
43-
root.crel=factory();
47+
root.crel=factory(root.window);
4448
}
45-
}(this,function(){
49+
}(this,function(window){
4650
// based on http://stackoverflow.com/questions/384286/javascript-isdom-how-do-you-check-if-a-javascript-object-is-a-dom-object
4751
varisNode=typeofNode==='object'
4852
?function(object){returnobjectinstanceofNode}

‎package.json‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name":"json-human",
3+
"version":"1.0.0",
4+
"description":"Convert JSON to human readable HTML",
5+
"main":"src/json.human.js",
6+
"scripts": {
7+
"test":"echo\"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type":"git",
11+
"url":"https://github.com/marianoguerra/json.human.js"
12+
},
13+
"keywords": [
14+
"json",
15+
"html",
16+
"human",
17+
"readable"
18+
],
19+
"author":"Mariano Guerra",
20+
"license":"MIT",
21+
"bugs": {
22+
"url":"https://github.com/marianoguerra/json.human.js/issues"
23+
},
24+
"homepage":"https://github.com/marianoguerra/json.human.js",
25+
"dependencies": {
26+
"jsdom":"^0.11.1"
27+
}
28+
}

‎src/json.human.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"use strict";
44
if(typeofdefine==='function'&&define.amd){
55
define(['crel'],factory);
6+
}elseif(typeofmodule!=='undefined'&&module.exports){
7+
module.exports=factory(require('../lib/crel'));
68
}else{
79
root.JsonHuman=factory(root.crel);
810
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp