dongnelibrary 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,14 +1,11 @@
1
1
  [![NPM Version][npm-image]][npm-url]
2
- [![Travis Build][travis-build-image]][travis-build-url]
3
2
  [![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php)
4
3
 
5
4
  # DongneLibrary
6
5
 
7
- > 도서관 책을 빌릴 수 있는지 확인하는 프로그램
8
-
6
+ > 도서관 책을 빌릴 수 있는지 검색
9
7
 
10
8
  도서관 이름을 생략하면 모든 도서관을 검색한다.
11
- [블로그](https://agvim.wordpress.com/2017/01/20/check-if-a-library-book-was-rented/)에서 간단한 설명을 볼 수 있다.
12
9
 
13
10
  ## install with git
14
11
 
@@ -59,38 +56,38 @@ dongne () {
59
56
  npm install dongnelibrary
60
57
 
61
58
  ```javascript
62
- const dl = require('dongnelibrary');
63
- dl.search({
64
- title: 'javascript',
65
- libraryName: ['여주','판교']
66
- }, function (err, book) {
67
- console.log(book.libraryName + ' "' + book.title + '"');
68
- book.booklist.forEach(function (book) {
69
- console.log((book.exist?' ✓ ':' ') +' '+ book.title);
70
- });
71
- }, function (err, books) {
72
- console.log(books.length + ' 개의 도서관을 검색했습니다.');
73
- });
59
+ const dl = require("dongnelibrary");
60
+ dl.search(
61
+ {
62
+ title: "javascript",
63
+ libraryName: ["여주", "판교"],
64
+ },
65
+ function (err, book) {
66
+ console.log(book.libraryName + ' "' + book.title + '"');
67
+ book.booklist.forEach(function (book) {
68
+ console.log((book.exist ? " ✓ " : " ✖ ") + " " + book.title);
69
+ });
70
+ },
71
+ function (err, books) {
72
+ console.log(books.length + " 개의 도서관을 검색했습니다.");
73
+ },
74
+ );
74
75
  ```
75
76
 
76
77
  ## 검색 가능한 도서관
77
78
 
78
- * [경기교육통합도서관][gg-url] (경기중앙교육도서관,경기평택교육도서관,경기광주교육도서관,경기여주가남교육도서관,경기포천교육도서관,경기김포교육도서관,경기과천교육도서관,경기성남교육도서관,경기화성교육도서관,경기의정부교육도서관,경기평생교육학습관)
79
- * [군포시도서관][gunpo-url] (산본도서관,당동도서관,대야도서관,어린이도서관,이동도서관,중앙도서관,누리천문대,시청북카페밥상머리,부곡도서관,당정문화도서관,동화나무어린이도서관,금정작은도서관,재궁꿈나무도서관,궁내동작은도서관,노루목작은도서관,버드나무에부는바람작은도서관,꿈쟁이도서관,우리마을도서관,북카페사랑아이엔지,산본역도서관,하늘정원작은도서관,꿈이지,꿈드림작은도서관,여담작은도서관)
80
- * [성남시도서관][snlib-url] (논골도서관,중원어린이도서관,중앙도서관,분당도서관,구미도서관,해오름도서관,중원도서관,무지개도서관,판교도서관,위례도서관,수정도서관,책테마파크도서관,운중도서관,서현도서관,복정도서관,판교어린이도서관)
81
- * [오산시도서관][osan-url] (중앙도서관,꿈두레도서관,초평도서관,햇살마루도서관,청학도서관,양산도서관,소리울도서관,무지개도서관,고현초꿈키움도서관,쌍용예가시민개방도서관)
82
- * [화성시립도서관][hscity-url] (남양도서관,태안도서관,삼괴도서관,병점도서관,샘내도서관,두빛나래도서관,봉담도서관,둥지나래도서관,목동이음터도서관,기아행복마루도서관,동탄복합문화센터도서관,송산도서관,정남도서관,비봉도서관,진안도서관,중앙이음터도서관,양감도서관,다원이음터도서관,송린이음터도서관,팔탄도서관,마도도서관,봉담커피앤북도서관,왕배푸른숲도서관,노을빛도서관,서연이음터도서관,호연이음터도서관,늘봄이음터도서관)
83
- * [수원시도서관][suwon-url] (선경도서관,중앙도서관,영통도서관,슬기샘도서관,바른샘도서관,지혜샘도서관,서수원도서관,북수원도서관,태장마루도서관,한아름도서관,반달어린이도서관,사랑샘도서관,희망샘도서관,화홍어린이도서관,대추골도서관,한림도서관,창룡도서관,버드내도서관,광교홍재도서관,호매실도서관,일월도서관,화서다산도서관,광교푸른숲도서관,매여울도서관,망포글빛도서관)
79
+ - [경기교육통합도서관][gg-url] (경기중앙교육도서관,경기평택교육도서관,경기광주교육도서관,경기여주가남교육도서관,경기포천교육도서관,경기김포교육도서관,경기과천교육도서관,경기성남교육도서관,경기화성교육도서관,경기의정부교육도서관,경기평생교육학습관)
80
+ - [군포시도서관][gunpo-url] (산본도서관,당동도서관,대야도서관,어린이도서관,이동도서관,중앙도서관,누리천문대,시청북카페밥상머리,부곡도서관,당정문화도서관,동화나무어린이도서관,금정작은도서관,재궁꿈나무도서관,궁내동작은도서관,노루목작은도서관,버드나무에부는바람작은도서관,꿈쟁이도서관,우리마을도서관,북카페사랑아이엔지,산본역도서관,하늘정원작은도서관,꿈이지,꿈드림작은도서관,여담작은도서관)
81
+ - [성남시도서관][snlib-url] (논골도서관,중원어린이도서관,중앙도서관,분당도서관,구미도서관,해오름도서관,중원도서관,무지개도서관,판교도서관,위례도서관,수정도서관,책테마파크도서관,운중도서관,서현도서관,복정도서관,판교어린이도서관)
82
+ - [오산시도서관][osan-url] (중앙도서관,꿈두레도서관,초평도서관,햇살마루도서관,청학도서관,양산도서관,소리울도서관,무지개도서관,고현초꿈키움도서관,쌍용예가시민개방도서관)
83
+ - [화성시립도서관][hscity-url] (남양도서관,태안도서관,삼괴도서관,병점도서관,샘내도서관,두빛나래도서관,봉담도서관,둥지나래도서관,목동이음터도서관,기아행복마루도서관,동탄복합문화센터도서관,송산도서관,정남도서관,비봉도서관,진안도서관,중앙이음터도서관,양감도서관,다원이음터도서관,송린이음터도서관,팔탄도서관,마도도서관,봉담커피앤북도서관,왕배푸른숲도서관,노을빛도서관,서연이음터도서관,호연이음터도서관,늘봄이음터도서관)
84
+ - [수원시도서관][suwon-url] (선경도서관,중앙도서관,창룡도서관,화서다산도서관,호매실도서관,서수원도서관,한림도서관,버드내도서관,북수원도서관,대추골도서관,일월도서관,광교홍재도서관,태장마루도서관,광교푸른숲도서관,매여울도서관,망포글빛도서관,슬기샘도서관,지혜샘어린이도서관,바른샘어린이도서관,한아름도서관,반달어린이도서관,사랑샘도서관,희망샘도서관)
84
85
 
85
86
  ## 마무리
86
87
 
87
88
  [온라인에서][sample-url] 테스트 할 수 있으며 명령어가 불편하다면 [웹 서비스][web-ui-url]를 사용할 수 있다.
88
- 웹 서비스가 느리다면 검색 서버를 [로컬에 설치][dongnelibraryspa] 할 수 있다.
89
89
  [Web API 서비스][web-api]도 지원한다.
90
90
 
91
- [![SPA for dongnelibrary](https://agvim.files.wordpress.com/2017/07/dongne23.png?w=128)](https://dongne.herokuapp.com/)
92
- [![APP for dongnelibrary](https://agvim.files.wordpress.com/2019/06/dlserver.png?w=128)](https://dlserver.herokuapp.com/app/)
93
-
94
91
  ## Test
95
92
 
96
93
  npm test
@@ -105,16 +102,12 @@ dl.search({
105
102
  [dongnelibraryspa]: https://github.com/afrontend/dongnelibraryspa "AngularJS, Foundation을 사용한 Web UI"
106
103
  [npm-image]: https://img.shields.io/npm/v/dongnelibrary.svg
107
104
  [npm-url]: https://npmjs.org/package/dongnelibrary
108
- [travis-build-image]: https://travis-ci.org/afrontend/dongnelibrary.svg?branch=master
109
- [travis-build-url]: https://travis-ci.org/afrontend/dongnelibrary
110
- [web-ui-url]: https://dongne.herokuapp.com "무료 서버라서 10초 정도 느리게 로딩될 수 있어요"
105
+ [web-ui-url]: https://dongne.onrender.com
111
106
  [web-api]: https://github.com/afrontend/dlserver "같은 기능을 지원하는 Web API"
112
-
113
- [gg-url]: http://www.gglib.or.kr
114
- [gunpo-url]: http://www.gunpolib.go.kr
107
+ [gg-url]: https://lib.goe.go.kr
108
+ [gunpo-url]: https://www.gunpolib.go.kr
115
109
  [hscity-url]: https://hscitylib.or.kr
116
- [osan-url]: http://www.osanlibrary.go.kr
117
- [snlib-url]: http://www.snlib.net
118
- [suwon-url]: http://www.suwonlib.go.kr
119
-
110
+ [osan-url]: https://www.osanlibrary.go.kr
111
+ [snlib-url]: https://www.snlib.go.kr
112
+ [suwon-url]: https://www.suwonlib.go.kr
120
113
  [sample-url]: https://npm.runkit.com/dongnelibrary
package/package.json CHANGED
@@ -3,11 +3,11 @@
3
3
  "engines": {
4
4
  "node": ">=16.0.0"
5
5
  },
6
- "version": "0.2.3",
6
+ "version": "0.2.5",
7
7
  "description": "책을 빌릴 수 있는지 확인한다.",
8
8
  "main": "src/dongnelibrary.js",
9
9
  "bin": {
10
- "dongnelibrary": "./src/cli.js"
10
+ "dongnelibrary": "src/cli.js"
11
11
  },
12
12
  "scripts": {
13
13
  "test": "mocha",
@@ -53,7 +53,6 @@
53
53
  "configstore": "^4.0.0",
54
54
  "figlet": "^1.2.1",
55
55
  "inquirer": "^6.2.2",
56
- "jquery": "^3.6.4",
57
56
  "jsdom": "^21.1.1",
58
57
  "lodash": "^4.17.20",
59
58
  "request": "^2.73.0"
package/src/cli.js CHANGED
@@ -1,39 +1,42 @@
1
1
  #!/usr/bin/env node
2
- const Configstore = require('configstore');
3
- const _ = require('lodash');
4
- const colors = require('colors');
5
- const figlet = require('figlet');
6
- const fp = require('lodash/fp');
7
- const inquirer = require('inquirer');
8
- const program = require('commander');
9
- const dl = require('./dongnelibrary');
10
- const util = require('./util');
11
- const pkg = require('../package.json');
2
+ const Configstore = require("configstore");
3
+ const _ = require("lodash");
4
+ const colors = require("colors");
5
+ const figlet = require("figlet");
6
+ const fp = require("lodash/fp");
7
+ const inquirer = require("inquirer");
8
+ const program = require("commander");
9
+ const dl = require("./dongnelibrary");
10
+ const util = require("./util");
11
+ const pkg = require("../package.json");
12
12
 
13
13
  const conf = new Configstore(pkg.name, {});
14
- const getDefaultLibrary = () => (conf.get('library'));
15
- const setDefaultLibrary = (name) => (conf.set('library', name));
16
- const getDefaultTitle = () => (conf.get('title') === undefined ? 'javascript' : conf.get('title'));
17
- const setDefaultTitle = (title) => (conf.set('title', title));
14
+ const getDefaultLibrary = () => conf.get("library");
15
+ const setDefaultLibrary = (name) => conf.set("library", name);
16
+ const getDefaultTitle = () =>
17
+ conf.get("title") === undefined ? "javascript" : conf.get("title");
18
+ const setDefaultTitle = (title) => conf.set("title", title);
18
19
 
19
20
  const introMessage = (msg) => {
20
- console.log(figlet.textSync(msg, {
21
- font: 'Standard',
22
- horizontalLayout: 'default',
23
- verticalLayout: 'default'
24
- }));
21
+ console.log(
22
+ figlet.textSync(msg, {
23
+ font: "Standard",
24
+ horizontalLayout: "default",
25
+ verticalLayout: "default",
26
+ }),
27
+ );
25
28
  };
26
29
 
27
30
  program
28
31
  .version(pkg.version)
29
- .option('-a, --library-list', 'Show libraries')
30
- .option('-i, --interactive', 'Use menu')
31
- .option('-l, --library-name [name,name]', 'library name')
32
- .option('-t, --title [title]', 'a part of book title')
32
+ .option("-a, --library-list", "Show libraries")
33
+ .option("-i, --interactive", "Use menu")
34
+ .option("-l, --library-name [name,name]", "library name")
35
+ .option("-t, --title [title]", "a part of book title")
33
36
  .parse(process.argv);
34
37
 
35
38
  function cutTail(str, tail) {
36
- let result = '';
39
+ let result = "";
37
40
  const index = str.indexOf(tail);
38
41
  if (index === -1) {
39
42
  result = str;
@@ -43,65 +46,83 @@ function cutTail(str, tail) {
43
46
  return result;
44
47
  }
45
48
 
46
- const okMark = '';
47
- const notokMark = '';
49
+ const okMark = "";
50
+ const notokMark = "";
48
51
 
49
52
  function printBooks(book) {
50
- _.each(book.booklist, book => {
51
- console.log(cutTail(book.libraryName, '도서관') + (book.exist?' ' + okMark + ' ':' ' + colors.red(notokMark) + ' ') + book.title + ' ');
53
+ _.each(book.booklist, (book) => {
54
+ console.log(
55
+ cutTail(book.libraryName, "도서관") +
56
+ (book.exist ? " " + okMark + " " : " " + colors.red(notokMark) + " ") +
57
+ book.title +
58
+ " ",
59
+ );
52
60
  });
53
61
  }
54
62
 
55
63
  function printAllLibraryName() {
56
64
  const libs = dl.getLibraryNames();
57
- libs.forEach(name => {
65
+ libs.forEach((name) => {
58
66
  console.log(name);
59
67
  });
60
68
  const msg = `모두 ${libs.length} 개의 도서관`;
61
69
  console.log(colors.green(msg));
62
70
  }
63
71
 
64
- const getFullLibraryName = str => _.find(dl.getLibraryNames(), name => (name.indexOf(str) >= 0));
72
+ const getFullLibraryName = (str) =>
73
+ _.find(dl.getLibraryNames(), (name) => name.indexOf(str) >= 0);
65
74
 
66
75
  function search(option, bookCallback, allBookCallback) {
67
- dl.search({
68
- title: option.title,
69
- libraryName: getLibraries(option.libraryName)
70
- }, (err, book) => {
71
- if (err) {
72
- err.msg = err.msg || "Unknown Error";
73
- if (bookCallback) {
74
- bookCallback(err);
75
- }
76
- } else {
77
- if (bookCallback) {
78
- bookCallback(null, book);
79
- }
80
- }
81
- }, (err, books) => {
82
- if (err) {
83
- err.msg = err.msg || "Unknown Error";
84
- if (allBookCallback) {
85
- allBookCallback(err);
76
+ dl.search(
77
+ {
78
+ title: option.title,
79
+ libraryName: getLibraries(option.libraryName),
80
+ },
81
+ (err, book) => {
82
+ if (err) {
83
+ err.msg = err.msg || "Unknown Error";
84
+ if (bookCallback) {
85
+ bookCallback(err);
86
+ }
87
+ } else {
88
+ if (bookCallback) {
89
+ bookCallback(null, book);
90
+ }
86
91
  }
87
- } else {
88
- if (allBookCallback) {
89
- allBookCallback(null, books);
92
+ },
93
+ (err, books) => {
94
+ if (err) {
95
+ err.msg = err.msg || "Unknown Error";
96
+ if (allBookCallback) {
97
+ allBookCallback(err);
98
+ }
99
+ } else {
100
+ if (allBookCallback) {
101
+ allBookCallback(null, books);
102
+ }
90
103
  }
91
- }
92
- });
104
+ },
105
+ );
93
106
  }
94
107
 
95
- const getBookCount = (results) => (
96
- _.reduce(results, (memo, book) => (memo + ((book && book.booklist && book.booklist.length) ? book.booklist.length : 0)), 0)
97
- );
108
+ const getBookCount = (results) =>
109
+ _.reduce(
110
+ results,
111
+ (memo, book) =>
112
+ memo +
113
+ (book && book.booklist && book.booklist.length
114
+ ? book.booklist.length
115
+ : 0),
116
+ 0,
117
+ );
98
118
 
99
119
  const getLibraryFullNameList = _.flow([
100
120
  util.getArrayFromCommaSeparatedString,
101
- fp.filter(shortLibraryName => (getFullLibraryName(shortLibraryName)))
121
+ fp.filter((shortLibraryName) => getFullLibraryName(shortLibraryName)),
102
122
  ]);
103
123
 
104
- const getLibraries = (libraryName) => (libraryName ? getLibraryFullNameList(libraryName) : dl.getLibraryNames());
124
+ const getLibraries = (libraryName) =>
125
+ libraryName ? getLibraryFullNameList(libraryName) : dl.getLibraryNames();
105
126
 
106
127
  const processOneLibrary = (err, book) => {
107
128
  if (err) {
@@ -113,9 +134,13 @@ const processOneLibrary = (err, book) => {
113
134
 
114
135
  const processLibraries = (err, results) => {
115
136
  if (err) {
116
- console.log('Error, Can\'t access detail information');
137
+ console.log("Error, Can't access detail information");
117
138
  } else {
118
- console.log(colors.green(`${results.length} 개의 도서관에서 ${getBookCount(results)} 권 검색됨`));
139
+ console.log(
140
+ colors.green(
141
+ `${results.length} 개의 도서관에서 ${getBookCount(results)} 권 검색됨`,
142
+ ),
143
+ );
119
144
  }
120
145
  };
121
146
 
@@ -126,26 +151,26 @@ function activate(option) {
126
151
  }
127
152
 
128
153
  if (option.interactive) {
129
- introMessage('Dongne Library');
154
+ introMessage("Dongne Library");
130
155
  inquirer
131
156
  .prompt([
132
157
  {
133
- type: 'list',
134
- name: 'library',
135
- message: '도서관 이름은?',
158
+ type: "list",
159
+ name: "library",
160
+ message: "도서관 이름은?",
136
161
  choices: dl.getLibraryNames(),
137
- default: getDefaultLibrary()
162
+ default: getDefaultLibrary(),
138
163
  },
139
164
  {
140
- type: 'input',
141
- name: 'title',
142
- message: '책 이름은?',
143
- default: getDefaultTitle()
144
- }
165
+ type: "input",
166
+ name: "title",
167
+ message: "책 이름은?",
168
+ default: getDefaultTitle(),
169
+ },
145
170
  ])
146
- .then(answers => {
147
- option.libraryName = answers['library'];
148
- option.title = answers['title'];
171
+ .then((answers) => {
172
+ option.libraryName = answers["library"];
173
+ option.title = answers["title"];
149
174
  setDefaultLibrary(option.libraryName);
150
175
  setDefaultTitle(option.title);
151
176
  if (option.libraryName && option.title) {
@@ -1,135 +1,132 @@
1
- const _ = require('lodash');
2
- const fp = require('lodash/fp');
3
- const gg = require('./library/gg');
4
- const gunpo = require('./library/gunpo');
5
- const hscity = require('./library/hscity');
6
- const osan = require('./library/osan');
7
- const snlib = require('./library/snlib');
8
- const suwon = require('./library/suwon');
9
- const async = require('async');
10
- const util = require('./util.js');
1
+ const _ = require("lodash");
2
+ const fp = require("lodash/fp");
3
+ const gg = require("./library/gg");
4
+ const gunpo = require("./library/gunpo");
5
+ const hscity = require("./library/hscity");
6
+ const osan = require("./library/osan");
7
+ const snlib = require("./library/snlib");
8
+ const suwon = require("./library/suwon");
9
+ const async = require("async");
10
+ const util = require("./util.js");
11
11
 
12
12
  const libraryList = [];
13
13
 
14
- const getLibraryNames = () => (util.getLibraryNames(libraryList));
14
+ const getLibraryNames = () => util.getLibraryNames(libraryList);
15
15
 
16
16
  function makeLibraryList() {
17
- const library = [
18
- gg,
19
- gunpo,
20
- hscity,
21
- osan,
22
- snlib,
23
- suwon
24
- ];
25
-
26
- _.each(library, library => {
27
- _.each(library.getLibraryNames(), name => {
17
+ const library = [gg, gunpo, hscity, osan, snlib, suwon];
18
+
19
+ _.each(library, (library) => {
20
+ _.each(library.getLibraryNames(), (name) => {
28
21
  libraryList.push({
29
22
  name,
30
- search: library.search
23
+ search: library.search,
31
24
  });
32
25
  });
33
26
  });
34
27
  }
35
28
 
36
- const getLibraryFunction = libraryName => {
37
- const found = _.find(libraryList, lib => (lib.name === libraryName));
38
- return found ? found : {
39
- search: (opt, getBook) => {
40
- if (getBook) {
41
- getBook({msg: 'Unknown library name'});
42
- }
43
- },
44
- name: 'Unknown'
45
- };
29
+ const getLibraryFunction = (libraryName) => {
30
+ const found = _.find(libraryList, (lib) => lib.name === libraryName);
31
+ return found
32
+ ? found
33
+ : {
34
+ search: (opt, getBook) => {
35
+ if (getBook) {
36
+ getBook({ msg: "Unknown library name" });
37
+ }
38
+ },
39
+ name: "Unknown",
40
+ };
46
41
  };
47
42
 
48
43
  function completeLibraryName(str) {
49
- const found = _.find(getLibraryNames(), name => (name.indexOf(str) >= 0));
50
- return found ? found : '';
44
+ const found = _.find(getLibraryNames(), (name) => name.indexOf(str) >= 0);
45
+ return found ? found : "";
51
46
  }
52
47
 
53
48
  function isValidLibraryName(libraryName) {
54
- const found = _.find(libraryList, lib => (lib.name === libraryName));
49
+ const found = _.find(libraryList, (lib) => lib.name === libraryName);
55
50
  return found ? true : false;
56
51
  }
57
52
 
58
53
  function getLibArray(libraryName) {
59
54
  return _.flow([
60
- fp.map(name => {
55
+ fp.map((name) => {
61
56
  const fullName = completeLibraryName(name);
62
57
  return isValidLibraryName(fullName) ? getLibraryFunction(fullName) : null;
63
58
  }),
64
- _.compact
59
+ _.compact,
65
60
  ])(Array.isArray(libraryName) ? libraryName : [libraryName]);
66
61
  }
67
62
 
68
63
  const getSortedBooks = _.flow([
69
- fp.map(book => ({
64
+ fp.map((book) => ({
70
65
  libraryName: book.libraryName,
71
66
  title: book.title,
72
- exist: book.exist
67
+ exist: book.exist,
73
68
  })),
74
- fp.sortBy(book => (!book.exist))
69
+ fp.sortBy((book) => !book.exist),
75
70
  ]);
76
71
 
77
72
  function search(opt, getBook, getAllBooks) {
78
73
  if (!opt || (!getBook && !getAllBooks)) {
79
- console.log('invalid search options');
74
+ console.log("invalid search options");
80
75
  return;
81
76
  }
82
77
 
83
78
  const title = opt.title;
84
79
  const tasks = [];
85
80
 
86
- _.each(getLibArray(opt.libraryName), lib => {
87
- tasks.push(callback => {
88
- lib.search({
89
- title: title,
90
- libraryName: lib.name
91
- }, (err, data) => {
92
- if (err) {
93
- if(getBook) {
94
- getBook(err);
81
+ _.each(getLibArray(opt.libraryName), (lib) => {
82
+ tasks.push((callback) => {
83
+ lib.search(
84
+ {
85
+ title: title,
86
+ libraryName: lib.name,
87
+ },
88
+ (err, data) => {
89
+ if (err) {
90
+ if (getBook) {
91
+ getBook(err);
92
+ }
93
+ callback(err);
94
+ return;
95
95
  }
96
- callback(err);
97
- return;
98
- }
99
- if(!data || !data.booklist) {
100
- if(getBook) {
101
- getBook({msg: 'invalid Data response'});
96
+ if (!data || !data.booklist) {
97
+ if (getBook) {
98
+ getBook({ msg: "invalid Data response" });
99
+ }
100
+ callback({ msg: "invalid Data response" });
101
+ return;
102
102
  }
103
- callback({msg: 'invalid Data response'});
104
- return;
105
- }
106
103
 
107
- const bookObj = {
108
- title: title,
109
- libraryName: lib.name,
110
- totalBookCount: data.totalBookCount,
111
- startPage: data.startPage,
112
- booklist: getSortedBooks(data.booklist)
113
- };
114
-
115
- if(getBook) {
116
- getBook(null, bookObj);
117
- }
118
- callback(null, bookObj);
119
- });
104
+ const bookObj = {
105
+ title: title,
106
+ libraryName: lib.name,
107
+ totalBookCount: data.totalBookCount,
108
+ startPage: data.startPage,
109
+ booklist: getSortedBooks(data.booklist),
110
+ };
111
+
112
+ if (getBook) {
113
+ getBook(null, bookObj);
114
+ }
115
+ callback(null, bookObj);
116
+ },
117
+ );
120
118
  });
121
119
  });
122
120
 
123
121
  async.parallel(tasks, (err, results) => {
124
- if(getAllBooks) {
125
- if(err) {
122
+ if (getAllBooks) {
123
+ if (err) {
126
124
  getAllBooks(err);
127
125
  } else {
128
126
  getAllBooks(null, results);
129
127
  }
130
128
  }
131
- });
132
-
129
+ });
133
130
  }
134
131
 
135
132
  function activate() {
@@ -140,5 +137,5 @@ activate();
140
137
 
141
138
  module.exports = {
142
139
  search,
143
- getLibraryNames
140
+ getLibraryNames,
144
141
  };
package/src/example.js CHANGED
@@ -1,16 +1,16 @@
1
- const dl = require('dongnelibrary');
2
- dl.search({
3
- title: 'javascript',
4
- libraryName: ['여주','판교']
5
- }, function (err, book) {
6
- console.log(book.libraryName + ' "' + book.title + '"');
7
- book.booklist.forEach(function (book) {
8
- console.log((book.exist?' ✓ ':' ') +' '+ book.title);
9
- });
10
- }, function (err, books) {
11
- console.log(books.length + ' 개의 도서관을 검색했습니다.');
12
- });
13
-
14
-
15
-
16
-
1
+ const dl = require("dongnelibrary");
2
+ dl.search(
3
+ {
4
+ title: "javascript",
5
+ libraryName: ["여주", "판교"],
6
+ },
7
+ function (err, book) {
8
+ console.log(book.libraryName + ' "' + book.title + '"');
9
+ book.booklist.forEach(function (book) {
10
+ console.log((book.exist ? " ✓ " : " ✖ ") + " " + book.title);
11
+ });
12
+ },
13
+ function (err, books) {
14
+ console.log(books.length + " 개의 도서관을 검색했습니다.");
15
+ },
16
+ );