김수민

commit

Showing 96 changed files with 4964 additions and 1 deletions
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
2 <project version="4"> 2 <project version="4">
3 <component name="ChangeListManager"> 3 <component name="ChangeListManager">
4 <list default="true" id="5c08ae96-2f87-46c1-b81d-f30e494ce252" name="Default Changelist" comment=""> 4 <list default="true" id="5c08ae96-2f87-46c1-b81d-f30e494ce252" name="Default Changelist" comment="">
5 - <change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
6 <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> 5 <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
7 <change beforePath="$PROJECT_DIR$/app.js" beforeDir="false" afterPath="$PROJECT_DIR$/app.js" afterDir="false" /> 6 <change beforePath="$PROJECT_DIR$/app.js" beforeDir="false" afterPath="$PROJECT_DIR$/app.js" afterDir="false" />
8 <change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" /> 7 <change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
...@@ -58,6 +57,7 @@ ...@@ -58,6 +57,7 @@
58 <workItem from="1573898557106" duration="89000" /> 57 <workItem from="1573898557106" duration="89000" />
59 <workItem from="1573899005304" duration="7410000" /> 58 <workItem from="1573899005304" duration="7410000" />
60 <workItem from="1574071758382" duration="6285000" /> 59 <workItem from="1574071758382" duration="6285000" />
60 + <workItem from="1574323490142" duration="7902000" />
61 </task> 61 </task>
62 <servers /> 62 <servers />
63 </component> 63 </component>
......
...@@ -105,10 +105,41 @@ function handleEvent(event) { ...@@ -105,10 +105,41 @@ function handleEvent(event) {
105 result.text = objBody.message.result.translatedText; 105 result.text = objBody.message.result.translatedText;
106 console.log(result.text); 106 console.log(result.text);
107 //번역된 문장 보내기 107 //번역된 문장 보내기
108 + let audio_options={
109 + 'Text': result.text,
110 + 'OutputFormat': 'mp3',
111 + 'VoiceId':'Seoyeon'
112 + };
113 + Polly.synthesizeSpeech(audio_options, (err, data) => {
114 + console.log("check");
115 + if (err) {
116 + throw err;
117 + } else if (data) {
118 + if (data.AudioStream instanceof Buffer) {
119 + fs.writeFile("./speech.mp3", data.AudioStream, function(err) {
120 + if (err) {
121 + return console.log(err);
122 + }
123 + console.log("The file was saved!");
124 + })
125 + }
126 + }
127 + });
128 + request.post(audio_options, function (error,response,body) {
129 + if(!error && response.statusCode == 200){
130 + for_audio_client.replyAudio(event.replyToken,{
131 + originalContentUrl: 'https://panguin.ml/speech.mp3',
132 + duration: 240000
133 + }).then(resolve).catch(reject);
134 + }
135 + });
108 client.replyMessage(event.replyToken,result).then(resolve).catch(reject); 136 client.replyMessage(event.replyToken,result).then(resolve).catch(reject);
109 137
110 } 138 }
111 }); 139 });
140 +
141 +
142 +
112 } 143 }
113 // 메시지의 언어가 영어 또는 한국어가 아닐 경우 144 // 메시지의 언어가 영어 또는 한국어가 아닐 경우
114 else{ 145 else{
......
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + "$basedir/node" "$basedir/../loose-envify/cli.js" "$@"
10 + ret=$?
11 +else
12 + node "$basedir/../loose-envify/cli.js" "$@"
13 + ret=$?
14 +fi
15 +exit $ret
1 +@IF EXIST "%~dp0\node.exe" (
2 + "%~dp0\node.exe" "%~dp0\..\loose-envify\cli.js" %*
3 +) ELSE (
4 + @SETLOCAL
5 + @SET PATHEXT=%PATHEXT:;.JS;=;%
6 + node "%~dp0\..\loose-envify\cli.js" %*
7 +)
...\ No newline at end of file ...\ No newline at end of file
1 +The MIT License (MIT)
2 +
3 +Copyright (c) 2017-present Yoctol (github.com/Yoctol/messaging-apis)
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in
13 +all copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 +THE SOFTWARE.
1 +# axios-error
2 +
3 +> An axios error wrapper that aim to provide clear error message to the user
4 +
5 +## Installation
6 +
7 +```sh
8 +npm i --save axios-error
9 +```
10 +
11 +or
12 +
13 +```sh
14 +yarn add axios-error
15 +```
16 +
17 +<br />
18 +
19 +## Usage
20 +
21 +```js
22 +const AxiosError = require('axios-error');
23 +
24 +// You can construct it from error throw by axios
25 +const error = new AxiosError(errorThrowByAxios);
26 +
27 +// Or with custom error message
28 +const error = new AxiosError(message, errorThrowByAxios);
29 +
30 +// Or construct it from axios config, axios request and axios response
31 +const error = new AxiosError(message, { config, request, response });
32 +```
33 +
34 +Directly `console.log` on the error instance will return formatted message. If you'd like to get the axios `request`, `response`, or `config`, you can still get them via those keys on the error instance.
35 +
36 +```js
37 +console.log(error); // formatted error message
38 +console.log(error.stack); // error stack trace
39 +console.log(error.config); // axios request config
40 +console.log(error.request); // HTTP request
41 +console.log(error.response); // HTTP response
42 +```
1 +"use strict";var _util = _interopRequireDefault(require("util"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
2 +
3 +function indent(str) {
4 + return str.
5 + split('\n').
6 + map(s => s ? ` ${s}` : '').
7 + join('\n');
8 +}
9 +
10 +function json(data) {
11 + return JSON.stringify(data, null, 2);
12 +}
13 +
14 +module.exports = class AxiosError extends Error {
15 + constructor(messageOrErr, _err = {}) {
16 + let err;
17 + if (messageOrErr instanceof Error) {
18 + super(messageOrErr.message);
19 + err = messageOrErr;
20 + } else {
21 + super(messageOrErr);
22 + err = _err;
23 + }
24 + const { config, request, response } = err;
25 +
26 + this.config = config;
27 + this.request = request;
28 + this.response = response;
29 + if (response && response.status) {
30 + this.status = response.status;
31 + }
32 + }
33 +
34 + // TODO: remove inspect until we drop node < 6.6
35 + inspect(...args) {
36 + return this[_util.default.inspect.custom](...args);
37 + }
38 +
39 + [_util.default.inspect.custom]() {
40 + let requestMessage = '';
41 +
42 + if (this.config) {
43 + let { data } = this.config;
44 +
45 + try {
46 + data = JSON.parse(data);
47 + } catch (_) {} // eslint-disable-line
48 +
49 + let requestData = '';
50 +
51 + if (this.config.data) {
52 + requestData = `
53 +Request Data -
54 +${indent(json(data))}`;
55 + }
56 +
57 + requestMessage = `
58 +Request -
59 + ${this.config.method.toUpperCase()} ${this.config.url}
60 +${requestData}`;
61 + }
62 +
63 + let responseMessage = '';
64 +
65 + if (this.response) {
66 + let responseData;
67 +
68 + if (this.response.data) {
69 + responseData = `
70 +Response Data -
71 +${indent(json(this.response.data))}`;
72 + }
73 +
74 + responseMessage = `
75 +Response -
76 + ${this.response.status} ${this.response.statusText}
77 +${responseData}`;
78 + }
79 +
80 + return `
81 +${this.stack}
82 +
83 +Error Message -
84 + ${this.message}
85 +${requestMessage}
86 +${responseMessage}
87 +`;
88 + }};
...\ No newline at end of file ...\ No newline at end of file
1 +{
2 + "_from": "axios-error@^0.8.1",
3 + "_id": "axios-error@0.8.1",
4 + "_inBundle": false,
5 + "_integrity": "sha512-4YIf0FK2aO8HHVAQXvVFK2oPQSsOh3P1WQjkwQwO3oFjq4vO3S3YSyiRzyebBIR4NmcHaMJ6W5m0iHuisG7lTA==",
6 + "_location": "/axios-error",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "axios-error@^0.8.1",
12 + "name": "axios-error",
13 + "escapedName": "axios-error",
14 + "rawSpec": "^0.8.1",
15 + "saveSpec": null,
16 + "fetchSpec": "^0.8.1"
17 + },
18 + "_requiredBy": [
19 + "/messaging-api-line"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/axios-error/-/axios-error-0.8.1.tgz",
22 + "_shasum": "4d9c21370465c290d07192e7f3eacfff49c256ae",
23 + "_spec": "axios-error@^0.8.1",
24 + "_where": "C:\\Users\\김수민\\Desktop\\ostt\\LINEBOT\\node_modules\\messaging-api-line",
25 + "bugs": {
26 + "url": "https://github.com/Yoctol/messaging-apis/issues"
27 + },
28 + "bundleDependencies": false,
29 + "deprecated": false,
30 + "description": "An axios error wrapper that aim to provide clear error message to the user",
31 + "devDependencies": {
32 + "axios": "^0.19.0",
33 + "axios-mock-adapter": "^1.17.0"
34 + },
35 + "engines": {
36 + "node": ">=8"
37 + },
38 + "gitHead": "622f5664634c26e752e4e54bd32dbc773271390f",
39 + "homepage": "https://github.com/Yoctol/messaging-apis#readme",
40 + "keywords": [
41 + "axios",
42 + "error",
43 + "http"
44 + ],
45 + "license": "MIT",
46 + "main": "lib/index.js",
47 + "name": "axios-error",
48 + "repository": {
49 + "type": "git",
50 + "url": "git+https://github.com/Yoctol/messaging-apis.git"
51 + },
52 + "version": "0.8.1"
53 +}
1 +// Jest Snapshot v1, https://goo.gl/fbAQLP
2 +
3 +exports[`should support error without axios data 1`] = `
4 +"
5 +Error: boom....
6 + at Object.<anonymous> (/Users/xxx/messaging-apis/packages/axios-error/src/__tests__/index.spec.js:16:19)
7 + at Generator.throw (<anonymous>)
8 + at step (/Users/xxx/messaging-apis/packages/axios-error/src/__tests__/index.spec.js:4:336)
9 + at /Users/xxx/messaging-apis/packages/axios-error/src/__tests__/index.spec.js:4:535
10 + at <anonymous>
11 +
12 +
13 +Error Message -
14 + custom error
15 +
16 +
17 +"
18 +`;
19 +
20 +exports[`should work 1`] = `
21 +"
22 +Error: boom....
23 + at Object.<anonymous> (/Users/xxx/messaging-apis/packages/axios-error/src/__tests__/index.spec.js:16:19)
24 + at Generator.throw (<anonymous>)
25 + at step (/Users/xxx/messaging-apis/packages/axios-error/src/__tests__/index.spec.js:4:336)
26 + at /Users/xxx/messaging-apis/packages/axios-error/src/__tests__/index.spec.js:4:535
27 + at <anonymous>
28 +
29 +
30 +Error Message -
31 + boom....
32 +
33 +Request -
34 + POST /
35 +
36 +Request Data -
37 + {
38 + \\"x\\": 1
39 + }
40 +
41 +Response -
42 + 400 Bad Request
43 +
44 +Response Data -
45 + {
46 + \\"error_status\\": \\"boom....\\"
47 + }
48 +"
49 +`;
50 +
51 +exports[`should work with construct using error instance only 1`] = `
52 +"
53 +Error: boom....
54 + at Object.<anonymous> (/Users/xxx/messaging-apis/packages/axios-error/src/__tests__/index.spec.js:16:19)
55 + at Generator.throw (<anonymous>)
56 + at step (/Users/xxx/messaging-apis/packages/axios-error/src/__tests__/index.spec.js:4:336)
57 + at /Users/xxx/messaging-apis/packages/axios-error/src/__tests__/index.spec.js:4:535
58 + at <anonymous>
59 +
60 +
61 +Error Message -
62 + Request failed with status code 400
63 +
64 +Request -
65 + POST /
66 +
67 +Request Data -
68 + {
69 + \\"x\\": 1
70 + }
71 +
72 +Response -
73 + 400 Bad Request
74 +
75 +Response Data -
76 + {
77 + \\"error_status\\": \\"boom....\\"
78 + }
79 +"
80 +`;
81 +
82 +exports[`should work with undefined response 1`] = `
83 +"
84 +Error: boom....
85 + at Object.<anonymous> (/Users/xxx/messaging-apis/packages/axios-error/src/__tests__/index.spec.js:16:19)
86 + at Generator.throw (<anonymous>)
87 + at step (/Users/xxx/messaging-apis/packages/axios-error/src/__tests__/index.spec.js:4:336)
88 + at /Users/xxx/messaging-apis/packages/axios-error/src/__tests__/index.spec.js:4:535
89 + at <anonymous>
90 +
91 +
92 +Error Message -
93 + read ECONNRESET
94 +
95 +Request -
96 + POST /
97 +
98 +Request Data -
99 + {
100 + \\"x\\": 1
101 + }
102 +
103 +"
104 +`;
1 +import util from 'util';
2 +
3 +import MockAdapter from 'axios-mock-adapter';
4 +import axios from 'axios';
5 +
6 +import AxiosError from '..';
7 +
8 +const mock = new MockAdapter(axios);
9 +
10 +mock.onAny().reply(400, {
11 + error_status: 'boom....',
12 +});
13 +
14 +const stack = `Error: boom....
15 + at Object.<anonymous> (/Users/xxx/messaging-apis/packages/axios-error/src/__tests__/index.spec.js:16:19)
16 + at Generator.throw (<anonymous>)
17 + at step (/Users/xxx/messaging-apis/packages/axios-error/src/__tests__/index.spec.js:4:336)
18 + at /Users/xxx/messaging-apis/packages/axios-error/src/__tests__/index.spec.js:4:535
19 + at <anonymous>
20 +`;
21 +
22 +it('should work', async () => {
23 + try {
24 + await axios.post('/', { x: 1 });
25 + } catch (err) {
26 + // overwrite because axios-mock-adapter set it to undefined
27 + err.response.statusText = 'Bad Request';
28 +
29 + const error = new AxiosError(err.response.data.error_status, err);
30 +
31 + // overwrite stack to test it
32 + error.stack = stack;
33 +
34 + expect(error[util.inspect.custom]()).toMatchSnapshot();
35 + }
36 +});
37 +
38 +it('should set `.status` property', async () => {
39 + try {
40 + await axios.post('/', { x: 1 });
41 + } catch (err) {
42 + // overwrite because axios-mock-adapter set it to undefined
43 + err.response.statusText = 'Bad Request';
44 +
45 + const error = new AxiosError(err);
46 +
47 + expect(error.status).toBe(400);
48 + }
49 +});
50 +
51 +it('should work with construct using error instance only', async () => {
52 + try {
53 + await axios.post('/', { x: 1 });
54 + } catch (err) {
55 + // overwrite because axios-mock-adapter set it to undefined
56 + err.response.statusText = 'Bad Request';
57 +
58 + const error = new AxiosError(err);
59 +
60 + // overwrite stack to test it
61 + error.stack = stack;
62 +
63 + expect(error[util.inspect.custom]()).toMatchSnapshot();
64 + }
65 +});
66 +
67 +it('should work with undefined response', async () => {
68 + try {
69 + await axios.post('/', { x: 1 });
70 + } catch (err) {
71 + // overwrite to undefined
72 + // https://github.com/Yoctol/bottender/issues/246
73 + err.response = undefined;
74 +
75 + const error = new AxiosError('read ECONNRESET', err);
76 +
77 + // overwrite stack to test it
78 + error.stack = stack;
79 +
80 + expect(error[util.inspect.custom]()).toMatchSnapshot();
81 + }
82 +});
83 +
84 +it('should support error without axios data', () => {
85 + const error = new AxiosError('custom error');
86 + error.stack = stack;
87 +
88 + expect(error[util.inspect.custom]()).toMatchSnapshot();
89 +});
1 +import util from 'util';
2 +
3 +function indent(str) {
4 + return str
5 + .split('\n')
6 + .map(s => (s ? ` ${s}` : ''))
7 + .join('\n');
8 +}
9 +
10 +function json(data) {
11 + return JSON.stringify(data, null, 2);
12 +}
13 +
14 +module.exports = class AxiosError extends Error {
15 + constructor(messageOrErr, _err = {}) {
16 + let err;
17 + if (messageOrErr instanceof Error) {
18 + super(messageOrErr.message);
19 + err = messageOrErr;
20 + } else {
21 + super(messageOrErr);
22 + err = _err;
23 + }
24 + const { config, request, response } = err;
25 +
26 + this.config = config;
27 + this.request = request;
28 + this.response = response;
29 + if (response && response.status) {
30 + this.status = response.status;
31 + }
32 + }
33 +
34 + // TODO: remove inspect until we drop node < 6.6
35 + inspect(...args) {
36 + return this[util.inspect.custom](...args);
37 + }
38 +
39 + [util.inspect.custom]() {
40 + let requestMessage = '';
41 +
42 + if (this.config) {
43 + let { data } = this.config;
44 +
45 + try {
46 + data = JSON.parse(data);
47 + } catch (_) {} // eslint-disable-line
48 +
49 + let requestData = '';
50 +
51 + if (this.config.data) {
52 + requestData = `
53 +Request Data -
54 +${indent(json(data))}`;
55 + }
56 +
57 + requestMessage = `
58 +Request -
59 + ${this.config.method.toUpperCase()} ${this.config.url}
60 +${requestData}`;
61 + }
62 +
63 + let responseMessage = '';
64 +
65 + if (this.response) {
66 + let responseData;
67 +
68 + if (this.response.data) {
69 + responseData = `
70 +Response Data -
71 +${indent(json(this.response.data))}`;
72 + }
73 +
74 + responseMessage = `
75 +Response -
76 + ${this.response.status} ${this.response.statusText}
77 +${responseData}`;
78 + }
79 +
80 + return `
81 +${this.stack}
82 +
83 +Error Message -
84 + ${this.message}
85 +${requestMessage}
86 +${responseMessage}
87 +`;
88 + }
89 +};
1 +/// <reference types="node"/>
2 +
3 +declare namespace imageType {
4 + type ImageType =
5 + | 'jpg'
6 + | 'png'
7 + | 'gif'
8 + | 'webp'
9 + | 'flif'
10 + | 'cr2'
11 + | 'tif'
12 + | 'bmp'
13 + | 'jxr'
14 + | 'psd'
15 + | 'ico'
16 + | 'bpg'
17 + | 'jp2'
18 + | 'jpm'
19 + | 'jpx'
20 + | 'heic'
21 + | 'cur'
22 + | 'dcm';
23 +
24 + interface ImageTypeResult {
25 + /**
26 + One of the supported [file types](https://github.com/sindresorhus/image-type#supported-file-types).
27 + */
28 + ext: ImageType;
29 +
30 + /**
31 + The detected [MIME type](https://en.wikipedia.org/wiki/Internet_media_type).
32 + */
33 + mime: string;
34 + }
35 +}
36 +
37 +declare const imageType: {
38 + /**
39 + Detect the image type of a `Buffer`/`Uint8Array`.
40 +
41 + @param input - Input to examine to determine the file type. It only needs the first `.minimumBytes` bytes.
42 +
43 + @example
44 + ```
45 + import readChunk = require('read-chunk');
46 + import imageType = require('image-type');
47 +
48 + const buffer = readChunk.sync('unicorn.png', 0, 12);
49 +
50 + imageType(buffer);
51 + //=> {ext: 'png', mime: 'image/png'}
52 +
53 +
54 + // Or from a remote location:
55 + import * as http from 'http';
56 +
57 + const url = 'https://assets-cdn.github.com/images/spinners/octocat-spinner-32.gif';
58 +
59 + http.get(url, response => {
60 + response.on('readable', () => {
61 + const chunk = response.read(imageType.minimumBytes);
62 + response.destroy();
63 + console.log(imageType(chunk));
64 + //=> {ext: 'gif', mime: 'image/gif'}
65 + });
66 + });
67 + ```
68 + */
69 + (input: Buffer | Uint8Array): imageType.ImageTypeResult | null;
70 +
71 + /**
72 + The minimum amount of bytes needed to detect a file type. Currently, it's 4100 bytes, but it can change, so don't hard-code it.
73 + */
74 + readonly minimumBytes: number;
75 +
76 + // TODO: Remove this for the next major release
77 + default: typeof imageType;
78 +};
79 +
80 +export = imageType;
1 +'use strict';
2 +const fileType = require('file-type');
3 +
4 +const imageExts = new Set([
5 + 'jpg',
6 + 'png',
7 + 'gif',
8 + 'webp',
9 + 'flif',
10 + 'cr2',
11 + 'tif',
12 + 'bmp',
13 + 'jxr',
14 + 'psd',
15 + 'ico',
16 + 'bpg',
17 + 'jp2',
18 + 'jpm',
19 + 'jpx',
20 + 'heic',
21 + 'cur',
22 + 'dcm'
23 +]);
24 +
25 +const imageType = input => {
26 + const ret = fileType(input);
27 + return imageExts.has(ret && ret.ext) ? ret : null;
28 +};
29 +
30 +module.exports = imageType;
31 +// TODO: Remove this for the next major release
32 +module.exports.default = imageType;
33 +
34 +Object.defineProperty(imageType, 'minimumBytes', {value: fileType.minimumBytes});
1 +MIT License
2 +
3 +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 +
7 +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 +
9 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +/// <reference types="node"/>
2 +import {Readable as ReadableStream} from 'stream';
3 +
4 +declare namespace fileType {
5 + type FileType =
6 + | 'jpg'
7 + | 'png'
8 + | 'gif'
9 + | 'webp'
10 + | 'flif'
11 + | 'cr2'
12 + | 'tif'
13 + | 'bmp'
14 + | 'jxr'
15 + | 'psd'
16 + | 'zip'
17 + | 'tar'
18 + | 'rar'
19 + | 'gz'
20 + | 'bz2'
21 + | '7z'
22 + | 'dmg'
23 + | 'mp4'
24 + | 'm4v'
25 + | 'mid'
26 + | 'mkv'
27 + | 'webm'
28 + | 'mov'
29 + | 'avi'
30 + | 'wmv'
31 + | 'mpg'
32 + | 'mp2'
33 + | 'mp3'
34 + | 'm4a'
35 + | 'ogg'
36 + | 'opus'
37 + | 'flac'
38 + | 'wav'
39 + | 'qcp'
40 + | 'amr'
41 + | 'pdf'
42 + | 'epub'
43 + | 'mobi'
44 + | 'exe'
45 + | 'swf'
46 + | 'rtf'
47 + | 'woff'
48 + | 'woff2'
49 + | 'eot'
50 + | 'ttf'
51 + | 'otf'
52 + | 'ico'
53 + | 'flv'
54 + | 'ps'
55 + | 'xz'
56 + | 'sqlite'
57 + | 'nes'
58 + | 'crx'
59 + | 'xpi'
60 + | 'cab'
61 + | 'deb'
62 + | 'ar'
63 + | 'rpm'
64 + | 'Z'
65 + | 'lz'
66 + | 'msi'
67 + | 'mxf'
68 + | 'mts'
69 + | 'wasm'
70 + | 'blend'
71 + | 'bpg'
72 + | 'docx'
73 + | 'pptx'
74 + | 'xlsx'
75 + | '3gp'
76 + | 'jp2'
77 + | 'jpm'
78 + | 'jpx'
79 + | 'mj2'
80 + | 'aif'
81 + | 'odt'
82 + | 'ods'
83 + | 'odp'
84 + | 'xml'
85 + | 'heic'
86 + | 'cur'
87 + | 'ktx'
88 + | 'ape'
89 + | 'wv'
90 + | 'asf'
91 + | 'wma'
92 + | 'wmv'
93 + | 'dcm'
94 + | 'mpc'
95 + | 'ics'
96 + | 'glb'
97 + | 'pcap';
98 +
99 + interface FileTypeResult {
100 + /**
101 + One of the supported [file types](https://github.com/sindresorhus/file-type#supported-file-types).
102 + */
103 + ext: FileType;
104 +
105 + /**
106 + The detected [MIME type](https://en.wikipedia.org/wiki/Internet_media_type).
107 + */
108 + mime: string;
109 + }
110 +
111 + type ReadableStreamWithFileType = ReadableStream & {
112 + readonly fileType: FileTypeResult | null;
113 + };
114 +}
115 +
116 +declare const fileType: {
117 + /**
118 + Detect the file type of a `Buffer`/`Uint8Array`/`ArrayBuffer`. The file type is detected by checking the [magic number](https://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files) of the buffer.
119 +
120 + @param buffer - It only needs the first `.minimumBytes` bytes. The exception is detection of `docx`, `pptx`, and `xlsx` which potentially requires reading the whole file.
121 + @returns An object with the detected file type and MIME type or `null` when there was no match.
122 +
123 + @example
124 + ```
125 + import readChunk = require('read-chunk');
126 + import fileType = require('file-type');
127 +
128 + const buffer = readChunk.sync('unicorn.png', 0, fileType.minimumBytes);
129 +
130 + fileType(buffer);
131 + //=> {ext: 'png', mime: 'image/png'}
132 +
133 +
134 + // Or from a remote location:
135 +
136 + import * as http from 'http';
137 +
138 + const url = 'https://assets-cdn.github.com/images/spinners/octocat-spinner-32.gif';
139 +
140 + http.get(url, response => {
141 + response.on('readable', () => {
142 + const chunk = response.read(fileType.minimumBytes);
143 + response.destroy();
144 + console.log(fileType(chunk));
145 + //=> {ext: 'gif', mime: 'image/gif'}
146 + });
147 + });
148 + ```
149 + */
150 + (buffer: Buffer | Uint8Array | ArrayBuffer): fileType.FileTypeResult | null;
151 +
152 + /**
153 + The minimum amount of bytes needed to detect a file type. Currently, it's 4100 bytes, but it can change, so don't hard-code it.
154 + */
155 + readonly minimumBytes: number;
156 +
157 + /**
158 + Detect the file type of a readable stream.
159 +
160 + @param readableStream - A readable stream containing a file to examine, see: [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable).
161 + @returns A `Promise` which resolves to the original readable stream argument, but with an added `fileType` property, which is an object like the one returned from `fileType()`.
162 +
163 + @example
164 + ```
165 + import * as fs from 'fs';
166 + import * as crypto from 'crypto';
167 + import fileType = require('file-type');
168 +
169 + (async () => {
170 + const read = fs.createReadStream('encrypted.enc');
171 + const decipher = crypto.createDecipheriv(alg, key, iv);
172 +
173 + const stream = await fileType.stream(read.pipe(decipher));
174 +
175 + console.log(stream.fileType);
176 + //=> {ext: 'mov', mime: 'video/quicktime'}
177 +
178 + const write = fs.createWriteStream(`decrypted.${stream.fileType.ext}`);
179 + stream.pipe(write);
180 + })();
181 + ```
182 + */
183 + readonly stream: (
184 + readableStream: ReadableStream
185 + ) => Promise<fileType.ReadableStreamWithFileType>;
186 +
187 + // TODO: Remove this for the next major release
188 + readonly default: typeof fileType;
189 +};
190 +
191 +export = fileType;
This diff is collapsed. Click to expand it.
1 +MIT License
2 +
3 +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 +
7 +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 +
9 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +{
2 + "_from": "file-type@^10.10.0",
3 + "_id": "file-type@10.11.0",
4 + "_inBundle": false,
5 + "_integrity": "sha512-uzk64HRpUZyTGZtVuvrjP0FYxzQrBf4rojot6J65YMEbwBLB0CWm0CLojVpwpmFmxcE/lkvYICgfcGozbBq6rw==",
6 + "_location": "/image-type/file-type",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "file-type@^10.10.0",
12 + "name": "file-type",
13 + "escapedName": "file-type",
14 + "rawSpec": "^10.10.0",
15 + "saveSpec": null,
16 + "fetchSpec": "^10.10.0"
17 + },
18 + "_requiredBy": [
19 + "/image-type"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/file-type/-/file-type-10.11.0.tgz",
22 + "_shasum": "2961d09e4675b9fb9a3ee6b69e9cd23f43fd1890",
23 + "_spec": "file-type@^10.10.0",
24 + "_where": "C:\\Users\\김수민\\Desktop\\ostt\\LINEBOT\\node_modules\\image-type",
25 + "author": {
26 + "name": "Sindre Sorhus",
27 + "email": "sindresorhus@gmail.com",
28 + "url": "sindresorhus.com"
29 + },
30 + "bugs": {
31 + "url": "https://github.com/sindresorhus/file-type/issues"
32 + },
33 + "bundleDependencies": false,
34 + "deprecated": false,
35 + "description": "Detect the file type of a Buffer/Uint8Array/ArrayBuffer",
36 + "devDependencies": {
37 + "@types/node": "^11.12.2",
38 + "ava": "^1.4.1",
39 + "pify": "^4.0.1",
40 + "read-chunk": "^3.2.0",
41 + "tsd": "^0.7.1",
42 + "xo": "^0.24.0"
43 + },
44 + "engines": {
45 + "node": ">=6"
46 + },
47 + "files": [
48 + "index.js",
49 + "index.d.ts"
50 + ],
51 + "homepage": "https://github.com/sindresorhus/file-type#readme",
52 + "keywords": [
53 + "mime",
54 + "file",
55 + "type",
56 + "archive",
57 + "image",
58 + "img",
59 + "pic",
60 + "picture",
61 + "flash",
62 + "photo",
63 + "video",
64 + "detect",
65 + "check",
66 + "is",
67 + "exif",
68 + "exe",
69 + "binary",
70 + "buffer",
71 + "uint8array",
72 + "jpg",
73 + "png",
74 + "gif",
75 + "webp",
76 + "flif",
77 + "cr2",
78 + "tif",
79 + "bmp",
80 + "jxr",
81 + "psd",
82 + "zip",
83 + "tar",
84 + "rar",
85 + "gz",
86 + "bz2",
87 + "7z",
88 + "dmg",
89 + "mp4",
90 + "m4v",
91 + "mid",
92 + "mkv",
93 + "webm",
94 + "mov",
95 + "avi",
96 + "mpg",
97 + "mp2",
98 + "mp3",
99 + "m4a",
100 + "ogg",
101 + "opus",
102 + "flac",
103 + "wav",
104 + "amr",
105 + "pdf",
106 + "epub",
107 + "mobi",
108 + "swf",
109 + "rtf",
110 + "woff",
111 + "woff2",
112 + "eot",
113 + "ttf",
114 + "otf",
115 + "ico",
116 + "flv",
117 + "ps",
118 + "xz",
119 + "sqlite",
120 + "xpi",
121 + "cab",
122 + "deb",
123 + "ar",
124 + "rpm",
125 + "Z",
126 + "lz",
127 + "msi",
128 + "mxf",
129 + "mts",
130 + "wasm",
131 + "webassembly",
132 + "blend",
133 + "bpg",
134 + "docx",
135 + "pptx",
136 + "xlsx",
137 + "3gp",
138 + "jp2",
139 + "jpm",
140 + "jpx",
141 + "mj2",
142 + "aif",
143 + "odt",
144 + "ods",
145 + "odp",
146 + "xml",
147 + "heic",
148 + "wma",
149 + "ics",
150 + "glb",
151 + "pcap"
152 + ],
153 + "license": "MIT",
154 + "name": "file-type",
155 + "repository": {
156 + "type": "git",
157 + "url": "git+https://github.com/sindresorhus/file-type.git"
158 + },
159 + "scripts": {
160 + "test": "xo && ava && tsd"
161 + },
162 + "version": "10.11.0"
163 +}
1 +# file-type [![Build Status](https://travis-ci.org/sindresorhus/file-type.svg?branch=master)](https://travis-ci.org/sindresorhus/file-type)
2 +
3 +> Detect the file type of a Buffer/Uint8Array/ArrayBuffer
4 +
5 +The file type is detected by checking the [magic number](https://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files) of the buffer.
6 +
7 +
8 +## Install
9 +
10 +```
11 +$ npm install file-type
12 +```
13 +
14 +<a href="https://www.patreon.com/sindresorhus">
15 + <img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
16 +</a>
17 +
18 +
19 +## Usage
20 +
21 +##### Node.js
22 +
23 +```js
24 +const readChunk = require('read-chunk');
25 +const fileType = require('file-type');
26 +
27 +const buffer = readChunk.sync('unicorn.png', 0, fileType.minimumBytes);
28 +
29 +fileType(buffer);
30 +//=> {ext: 'png', mime: 'image/png'}
31 +```
32 +
33 +Or from a remote location:
34 +
35 +```js
36 +const http = require('http');
37 +const fileType = require('file-type');
38 +
39 +const url = 'https://assets-cdn.github.com/images/spinners/octocat-spinner-32.gif';
40 +
41 +http.get(url, response => {
42 + response.on('readable', () => {
43 + const chunk = response.read(fileType.minimumBytes);
44 + response.destroy();
45 + console.log(fileType(chunk));
46 + //=> {ext: 'gif', mime: 'image/gif'}
47 + });
48 +});
49 +```
50 +
51 +Or from a stream:
52 +
53 +```js
54 +const fs = require('fs');
55 +const crypto = require('crypto');
56 +const fileType = require('file-type');
57 +
58 +(async () => {
59 + const read = fs.createReadStream('encrypted.enc');
60 + const decipher = crypto.createDecipheriv(alg, key, iv);
61 +
62 + const stream = await fileType.stream(read.pipe(decipher));
63 +
64 + console.log(stream.fileType);
65 + //=> {ext: 'mov', mime: 'video/quicktime'}
66 +
67 + const write = fs.createWriteStream(`decrypted.${stream.fileType.ext}`);
68 + stream.pipe(write);
69 +})();
70 +```
71 +
72 +
73 +##### Browser
74 +
75 +```js
76 +const xhr = new XMLHttpRequest();
77 +xhr.open('GET', 'unicorn.png');
78 +xhr.responseType = 'arraybuffer';
79 +
80 +xhr.onload = () => {
81 + fileType(new Uint8Array(this.response));
82 + //=> {ext: 'png', mime: 'image/png'}
83 +};
84 +
85 +xhr.send();
86 +```
87 +
88 +
89 +## API
90 +
91 +### fileType(input)
92 +
93 +Returns an `Object` with:
94 +
95 +- `ext` - One of the [supported file types](#supported-file-types)
96 +- `mime` - The [MIME type](https://en.wikipedia.org/wiki/Internet_media_type)
97 +
98 +Or `null` when there is no match.
99 +
100 +#### input
101 +
102 +Type: `Buffer | Uint8Array | ArrayBuffer`
103 +
104 +It only needs the first `.minimumBytes` bytes. The exception is detection of `docx`, `pptx`, and `xlsx` which potentially requires reading the whole file.
105 +
106 +### fileType.minimumBytes
107 +
108 +Type: `number`
109 +
110 +The minimum amount of bytes needed to detect a file type. Currently, it's 4100 bytes, but it can change, so don't hardcode it.
111 +
112 +### fileType.stream(readableStream)
113 +
114 +Detect the file type of a readable stream.
115 +
116 +Returns a `Promise` which resolves to the original readable stream argument, but with an added `fileType` property, which is an object like the one returned from `fileType()`.
117 +
118 +*Note:* This method is only for Node.js.
119 +
120 +#### readableStream
121 +
122 +Type: [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable)
123 +
124 +
125 +## Supported file types
126 +
127 +- [`jpg`](https://en.wikipedia.org/wiki/JPEG)
128 +- [`png`](https://en.wikipedia.org/wiki/Portable_Network_Graphics)
129 +- [`gif`](https://en.wikipedia.org/wiki/GIF)
130 +- [`webp`](https://en.wikipedia.org/wiki/WebP)
131 +- [`flif`](https://en.wikipedia.org/wiki/Free_Lossless_Image_Format)
132 +- [`cr2`](https://fileinfo.com/extension/cr2)
133 +- [`tif`](https://en.wikipedia.org/wiki/Tagged_Image_File_Format)
134 +- [`bmp`](https://en.wikipedia.org/wiki/BMP_file_format)
135 +- [`jxr`](https://en.wikipedia.org/wiki/JPEG_XR)
136 +- [`psd`](https://en.wikipedia.org/wiki/Adobe_Photoshop#File_format)
137 +- [`zip`](https://en.wikipedia.org/wiki/Zip_(file_format))
138 +- [`tar`](https://en.wikipedia.org/wiki/Tar_(computing)#File_format)
139 +- [`rar`](https://en.wikipedia.org/wiki/RAR_(file_format))
140 +- [`gz`](https://en.wikipedia.org/wiki/Gzip)
141 +- [`bz2`](https://en.wikipedia.org/wiki/Bzip2)
142 +- [`7z`](https://en.wikipedia.org/wiki/7z)
143 +- [`dmg`](https://en.wikipedia.org/wiki/Apple_Disk_Image)
144 +- [`mp4`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#Filename_extensions)
145 +- [`m4v`](https://en.wikipedia.org/wiki/M4V)
146 +- [`mid`](https://en.wikipedia.org/wiki/MIDI)
147 +- [`mkv`](https://en.wikipedia.org/wiki/Matroska)
148 +- [`webm`](https://en.wikipedia.org/wiki/WebM)
149 +- [`mov`](https://en.wikipedia.org/wiki/QuickTime_File_Format)
150 +- [`avi`](https://en.wikipedia.org/wiki/Audio_Video_Interleave)
151 +- [`wmv`](https://en.wikipedia.org/wiki/Windows_Media_Video)
152 +- [`mpg`](https://en.wikipedia.org/wiki/MPEG-1)
153 +- [`mp2`](https://en.wikipedia.org/wiki/MPEG-1_Audio_Layer_II)
154 +- [`mp3`](https://en.wikipedia.org/wiki/MP3)
155 +- [`m4a`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#.MP4_versus_.M4A)
156 +- [`ogg`](https://en.wikipedia.org/wiki/Ogg)
157 +- [`opus`](https://en.wikipedia.org/wiki/Opus_(audio_format))
158 +- [`flac`](https://en.wikipedia.org/wiki/FLAC)
159 +- [`wav`](https://en.wikipedia.org/wiki/WAV)
160 +- [`qcp`](https://en.wikipedia.org/wiki/QCP)
161 +- [`amr`](https://en.wikipedia.org/wiki/Adaptive_Multi-Rate_audio_codec)
162 +- [`pdf`](https://en.wikipedia.org/wiki/Portable_Document_Format)
163 +- [`epub`](https://en.wikipedia.org/wiki/EPUB)
164 +- [`mobi`](https://en.wikipedia.org/wiki/Mobipocket) - Mobipocket
165 +- [`exe`](https://en.wikipedia.org/wiki/.exe)
166 +- [`swf`](https://en.wikipedia.org/wiki/SWF)
167 +- [`rtf`](https://en.wikipedia.org/wiki/Rich_Text_Format)
168 +- [`woff`](https://en.wikipedia.org/wiki/Web_Open_Font_Format)
169 +- [`woff2`](https://en.wikipedia.org/wiki/Web_Open_Font_Format)
170 +- [`eot`](https://en.wikipedia.org/wiki/Embedded_OpenType)
171 +- [`ttf`](https://en.wikipedia.org/wiki/TrueType)
172 +- [`otf`](https://en.wikipedia.org/wiki/OpenType)
173 +- [`ico`](https://en.wikipedia.org/wiki/ICO_(file_format))
174 +- [`flv`](https://en.wikipedia.org/wiki/Flash_Video)
175 +- [`ps`](https://en.wikipedia.org/wiki/Postscript)
176 +- [`xz`](https://en.wikipedia.org/wiki/Xz)
177 +- [`sqlite`](https://www.sqlite.org/fileformat2.html)
178 +- [`nes`](https://fileinfo.com/extension/nes)
179 +- [`crx`](https://developer.chrome.com/extensions/crx)
180 +- [`xpi`](https://en.wikipedia.org/wiki/XPInstall)
181 +- [`cab`](https://en.wikipedia.org/wiki/Cabinet_(file_format))
182 +- [`deb`](https://en.wikipedia.org/wiki/Deb_(file_format))
183 +- [`ar`](https://en.wikipedia.org/wiki/Ar_(Unix))
184 +- [`rpm`](https://fileinfo.com/extension/rpm)
185 +- [`Z`](https://fileinfo.com/extension/z)
186 +- [`lz`](https://en.wikipedia.org/wiki/Lzip)
187 +- [`msi`](https://en.wikipedia.org/wiki/Windows_Installer)
188 +- [`mxf`](https://en.wikipedia.org/wiki/Material_Exchange_Format)
189 +- [`mts`](https://en.wikipedia.org/wiki/.m2ts)
190 +- [`wasm`](https://en.wikipedia.org/wiki/WebAssembly)
191 +- [`blend`](https://wiki.blender.org/index.php/Dev:Source/Architecture/File_Format)
192 +- [`bpg`](https://bellard.org/bpg/)
193 +- [`docx`](https://en.wikipedia.org/wiki/Office_Open_XML)
194 +- [`pptx`](https://en.wikipedia.org/wiki/Office_Open_XML)
195 +- [`xlsx`](https://en.wikipedia.org/wiki/Office_Open_XML)
196 +- [`3gp`](https://en.wikipedia.org/wiki/3GP_and_3G2)
197 +- [`jp2`](https://en.wikipedia.org/wiki/JPEG_2000) - JPEG 2000
198 +- [`jpm`](https://en.wikipedia.org/wiki/JPEG_2000) - JPEG 2000
199 +- [`jpx`](https://en.wikipedia.org/wiki/JPEG_2000) - JPEG 2000
200 +- [`mj2`](https://en.wikipedia.org/wiki/Motion_JPEG_2000) - Motion JPEG 2000
201 +- [`aif`](https://en.wikipedia.org/wiki/Audio_Interchange_File_Format)
202 +- [`odt`](https://en.wikipedia.org/wiki/OpenDocument) - OpenDocument for word processing
203 +- [`ods`](https://en.wikipedia.org/wiki/OpenDocument) - OpenDocument for spreadsheets
204 +- [`odp`](https://en.wikipedia.org/wiki/OpenDocument) - OpenDocument for presentations
205 +- [`xml`](https://en.wikipedia.org/wiki/XML)
206 +- [`heic`](https://nokiatech.github.io/heif/technical.html)
207 +- [`cur`](https://en.wikipedia.org/wiki/ICO_(file_format))
208 +- [`ktx`](https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/)
209 +- [`ape`](https://en.wikipedia.org/wiki/Monkey%27s_Audio) - Monkey's Audio
210 +- [`wv`](https://en.wikipedia.org/wiki/WavPack) - WavPack
211 +- [`asf`](https://en.wikipedia.org/wiki/Advanced_Systems_Format) - Advanced Systems Format
212 +- [`wma`](https://en.wikipedia.org/wiki/Windows_Media_Audio) - Windows Media Audio
213 +- [`wmv`](https://en.wikipedia.org/wiki/Windows_Media_Video) - Windows Media Video
214 +- [`dcm`](https://en.wikipedia.org/wiki/DICOM#Data_format) - DICOM Image File
215 +- [`mpc`](https://en.wikipedia.org/wiki/Musepack) - Musepack (SV7 & SV8)
216 +- [`ics`](https://en.wikipedia.org/wiki/ICalendar#Data_format) - iCalendar
217 +- [`glb`](https://github.com/KhronosGroup/glTF) - GL Transmission Format
218 +- [`pcap`](https://wiki.wireshark.org/Development/LibpcapFileFormat) - Libpcap File Format
219 +
220 +*SVG isn't included as it requires the whole file to be read, but you can get it [here](https://github.com/sindresorhus/is-svg).*
221 +
222 +*Pull request welcome for additional commonly used file types.*
223 +
224 +
225 +## Related
226 +
227 +- [file-type-cli](https://github.com/sindresorhus/file-type-cli) - CLI for this module
228 +
229 +
230 +## Created by
231 +
232 +- [Sindre Sorhus](https://github.com/sindresorhus)
233 +- [Mikael Finstad](https://github.com/mifi)
234 +
235 +
236 +## License
237 +
238 +MIT
1 +{
2 + "_from": "image-type@^4.1.0",
3 + "_id": "image-type@4.1.0",
4 + "_inBundle": false,
5 + "_integrity": "sha512-CFJMJ8QK8lJvRlTCEgarL4ro6hfDQKif2HjSvYCdQZESaIPV4v9imrf7BQHK+sQeTeNeMpWciR9hyC/g8ybXEg==",
6 + "_location": "/image-type",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "image-type@^4.1.0",
12 + "name": "image-type",
13 + "escapedName": "image-type",
14 + "rawSpec": "^4.1.0",
15 + "saveSpec": null,
16 + "fetchSpec": "^4.1.0"
17 + },
18 + "_requiredBy": [
19 + "/messaging-api-line"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/image-type/-/image-type-4.1.0.tgz",
22 + "_shasum": "72a88d64ff5021371ed67b9a466442100be57cd1",
23 + "_spec": "image-type@^4.1.0",
24 + "_where": "C:\\Users\\김수민\\Desktop\\ostt\\LINEBOT\\node_modules\\messaging-api-line",
25 + "author": {
26 + "name": "Sindre Sorhus",
27 + "email": "sindresorhus@gmail.com",
28 + "url": "sindresorhus.com"
29 + },
30 + "bugs": {
31 + "url": "https://github.com/sindresorhus/image-type/issues"
32 + },
33 + "bundleDependencies": false,
34 + "dependencies": {
35 + "file-type": "^10.10.0"
36 + },
37 + "deprecated": false,
38 + "description": "Detect the image type of a Buffer/Uint8Array",
39 + "devDependencies": {
40 + "@types/node": "^11.13.0",
41 + "ava": "^1.4.1",
42 + "read-chunk": "^3.2.0",
43 + "tsd": "^0.7.2",
44 + "xo": "^0.24.0"
45 + },
46 + "engines": {
47 + "node": ">=6"
48 + },
49 + "files": [
50 + "index.js",
51 + "index.d.ts"
52 + ],
53 + "homepage": "https://github.com/sindresorhus/image-type#readme",
54 + "keywords": [
55 + "image",
56 + "img",
57 + "pic",
58 + "picture",
59 + "photo",
60 + "type",
61 + "detect",
62 + "check",
63 + "is",
64 + "exif",
65 + "binary",
66 + "buffer",
67 + "uint8array",
68 + "png",
69 + "jpg",
70 + "jpeg",
71 + "gif",
72 + "webp",
73 + "tif",
74 + "bmp",
75 + "jxr",
76 + "psd",
77 + "mime"
78 + ],
79 + "license": "MIT",
80 + "name": "image-type",
81 + "repository": {
82 + "type": "git",
83 + "url": "git+https://github.com/sindresorhus/image-type.git"
84 + },
85 + "scripts": {
86 + "test": "xo && ava && tsd"
87 + },
88 + "version": "4.1.0"
89 +}
1 +# image-type [![Build Status](https://travis-ci.org/sindresorhus/image-type.svg?branch=master)](https://travis-ci.org/sindresorhus/image-type)
2 +
3 +> Detect the image type of a Buffer/Uint8Array
4 +
5 +See the [`file-type`](https://github.com/sindresorhus/file-type) module for more file types and a CLI.
6 +
7 +
8 +## Install
9 +
10 +```
11 +$ npm install image-type
12 +```
13 +
14 +
15 +## Usage
16 +
17 +##### Node.js
18 +
19 +```js
20 +const readChunk = require('read-chunk');
21 +const imageType = require('image-type');
22 +
23 +const buffer = readChunk.sync('unicorn.png', 0, 12);
24 +
25 +imageType(buffer);
26 +//=> {ext: 'png', mime: 'image/png'}
27 +```
28 +
29 +Or from a remote location:
30 +
31 +```js
32 +const http = require('http');
33 +const imageType = require('image-type');
34 +
35 +const url = 'https://assets-cdn.github.com/images/spinners/octocat-spinner-32.gif';
36 +
37 +http.get(url, response => {
38 + response.on('readable', () => {
39 + const chunk = response.read(imageType.minimumBytes);
40 + response.destroy();
41 + console.log(imageType(chunk));
42 + //=> {ext: 'gif', mime: 'image/gif'}
43 + });
44 +});
45 +```
46 +
47 +##### Browser
48 +
49 +```js
50 +const xhr = new XMLHttpRequest();
51 +xhr.open('GET', 'unicorn.png');
52 +xhr.responseType = 'arraybuffer';
53 +
54 +xhr.onload = () => {
55 + imageType(new Uint8Array(this.response));
56 + //=> {ext: 'png', mime: 'image/png'}
57 +};
58 +
59 +xhr.send();
60 +```
61 +
62 +
63 +## API
64 +
65 +### imageType(input)
66 +
67 +Returns an `Object` with:
68 +
69 +- `ext` - One of the [supported file types](#supported-file-types)
70 +- `mime` - The [MIME type](http://en.wikipedia.org/wiki/Internet_media_type)
71 +
72 +Or `null` when there is no match.
73 +
74 +#### input
75 +
76 +Type: `Buffer | Uint8Array`
77 +
78 +It only needs the first `.minimumBytes` bytes.
79 +
80 +### imageType.minimumBytes
81 +
82 +Type: `number`
83 +
84 +The minimum amount of bytes needed to detect a file type. Currently, it's 4100 bytes, but it can change, so don't hardcode it.
85 +
86 +
87 +## Supported file types
88 +
89 +- [`jpg`](https://en.wikipedia.org/wiki/JPEG)
90 +- [`png`](https://en.wikipedia.org/wiki/Portable_Network_Graphics)
91 +- [`gif`](https://en.wikipedia.org/wiki/GIF)
92 +- [`webp`](https://en.wikipedia.org/wiki/WebP)
93 +- [`flif`](https://en.wikipedia.org/wiki/Free_Lossless_Image_Format)
94 +- [`cr2`](https://fileinfo.com/extension/cr2)
95 +- [`tif`](https://en.wikipedia.org/wiki/Tagged_Image_File_Format)
96 +- [`bmp`](https://en.wikipedia.org/wiki/BMP_file_format)
97 +- [`jxr`](https://en.wikipedia.org/wiki/JPEG_XR)
98 +- [`psd`](https://en.wikipedia.org/wiki/Adobe_Photoshop#File_format)
99 +- [`ico`](https://en.wikipedia.org/wiki/ICO_(file_format))
100 +- [`bpg`](https://bellard.org/bpg/)
101 +- [`jp2`](https://en.wikipedia.org/wiki/JPEG_2000) - JPEG 2000
102 +- [`jpm`](https://en.wikipedia.org/wiki/JPEG_2000) - JPEG 2000
103 +- [`jpx`](https://en.wikipedia.org/wiki/JPEG_2000) - JPEG 2000
104 +- [`heic`](https://nokiatech.github.io/heif/technical.html)
105 +- [`cur`](https://en.wikipedia.org/wiki/ICO_(file_format))
106 +- [`dcm`](https://en.wikipedia.org/wiki/DICOM#Data_format) - DICOM Image File
107 +
108 +*SVG isn't included as it requires the whole file to be read, but you can get it [here](https://github.com/sindresorhus/is-svg).*
109 +
110 +
111 +## License
112 +
113 +MIT © [Sindre Sorhus](https://sindresorhus.com)
1 +2.2.4 / 2018-03-13
2 +==================
3 +
4 + * Use flow strict mode (i.e. `@flow strict`).
5 +
6 +2.2.3 / 2018-02-19
7 +==================
8 +
9 + * Change license from BSD+Patents to MIT.
10 +
11 +2.2.2 / 2016-11-15
12 +==================
13 +
14 + * Add LICENSE file.
15 + * Misc housekeeping.
16 +
17 +2.2.1 / 2016-03-09
18 +==================
19 +
20 + * Use `NODE_ENV` variable instead of `__DEV__` to cache `process.env.NODE_ENV`.
21 +
22 +2.2.0 / 2015-11-17
23 +==================
24 +
25 + * Use `error.name` instead of `Invariant Violation`.
26 +
27 +2.1.3 / 2015-11-17
28 +==================
29 +
30 + * Remove `@provideModule` pragma.
31 +
32 +2.1.2 / 2015-10-27
33 +==================
34 +
35 + * Fix license.
36 +
37 +2.1.1 / 2015-09-20
38 +==================
39 +
40 + * Use correct SPDX license.
41 + * Test "browser.js" using browserify.
42 + * Switch from "envify" to "loose-envify".
43 +
44 +2.1.0 / 2015-06-03
45 +==================
46 +
47 + * Add "envify" as a dependency.
48 + * Fixed license field in "package.json".
49 +
50 +2.0.0 / 2015-02-21
51 +==================
52 +
53 + * Switch to using the "browser" field. There are now browser and server versions that respect the "format" in production.
54 +
55 +1.0.2 / 2014-09-24
56 +==================
57 +
58 + * Added tests, npmignore and gitignore.
59 + * Clarifications in README.
60 +
61 +1.0.1 / 2014-09-24
62 +==================
63 +
64 + * Actually include 'invariant.js'.
65 +
66 +1.0.0 / 2014-09-24
67 +==================
68 +
69 + * Initial release.
1 +MIT License
2 +
3 +Copyright (c) 2013-present, Facebook, Inc.
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in all
13 +copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 +SOFTWARE.
1 +# invariant
2 +
3 +[![Build Status](https://travis-ci.org/zertosh/invariant.svg?branch=master)](https://travis-ci.org/zertosh/invariant)
4 +
5 +A mirror of Facebook's `invariant` (e.g. [React](https://github.com/facebook/react/blob/v0.13.3/src/vendor/core/invariant.js), [flux](https://github.com/facebook/flux/blob/2.0.2/src/invariant.js)).
6 +
7 +A way to provide descriptive errors in development but generic errors in production.
8 +
9 +## Install
10 +
11 +With [npm](http://npmjs.org) do:
12 +
13 +```sh
14 +npm install invariant
15 +```
16 +
17 +## `invariant(condition, message)`
18 +
19 +```js
20 +var invariant = require('invariant');
21 +
22 +invariant(someTruthyVal, 'This will not throw');
23 +// No errors
24 +
25 +invariant(someFalseyVal, 'This will throw an error with this message');
26 +// Error: Invariant Violation: This will throw an error with this message
27 +```
28 +
29 +**Note:** When `process.env.NODE_ENV` is not `production`, the message is required. If omitted, `invariant` will throw regardless of the truthiness of the condition. When `process.env.NODE_ENV` is `production`, the message is optional – so they can be minified away.
30 +
31 +### Browser
32 +
33 +When used with [browserify](https://github.com/substack/node-browserify), it'll use `browser.js` (instead of `invariant.js`) and the [envify](https://github.com/hughsk/envify) transform will inline the value of `process.env.NODE_ENV`.
34 +
35 +### Node
36 +
37 +The node version is optimized around the performance implications of accessing `process.env`. The value of `process.env.NODE_ENV` is cached, and repeatedly used instead of reading `process.env`. See [Server rendering is slower with npm react #812](https://github.com/facebook/react/issues/812)
1 +/**
2 + * Copyright (c) 2013-present, Facebook, Inc.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + */
7 +
8 +'use strict';
9 +
10 +/**
11 + * Use invariant() to assert state which your program assumes to be true.
12 + *
13 + * Provide sprintf-style format (only %s is supported) and arguments
14 + * to provide information about what broke and what you were
15 + * expecting.
16 + *
17 + * The invariant message will be stripped in production, but the invariant
18 + * will remain to ensure logic does not differ in production.
19 + */
20 +
21 +var invariant = function(condition, format, a, b, c, d, e, f) {
22 + if (process.env.NODE_ENV !== 'production') {
23 + if (format === undefined) {
24 + throw new Error('invariant requires an error message argument');
25 + }
26 + }
27 +
28 + if (!condition) {
29 + var error;
30 + if (format === undefined) {
31 + error = new Error(
32 + 'Minified exception occurred; use the non-minified dev environment ' +
33 + 'for the full error message and additional helpful warnings.'
34 + );
35 + } else {
36 + var args = [a, b, c, d, e, f];
37 + var argIndex = 0;
38 + error = new Error(
39 + format.replace(/%s/g, function() { return args[argIndex++]; })
40 + );
41 + error.name = 'Invariant Violation';
42 + }
43 +
44 + error.framesToPop = 1; // we don't care about invariant's own frame
45 + throw error;
46 + }
47 +};
48 +
49 +module.exports = invariant;
1 +/**
2 + * Copyright (c) 2013-present, Facebook, Inc.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + */
7 +
8 +'use strict';
9 +
10 +/**
11 + * Use invariant() to assert state which your program assumes to be true.
12 + *
13 + * Provide sprintf-style format (only %s is supported) and arguments
14 + * to provide information about what broke and what you were
15 + * expecting.
16 + *
17 + * The invariant message will be stripped in production, but the invariant
18 + * will remain to ensure logic does not differ in production.
19 + */
20 +
21 +var NODE_ENV = process.env.NODE_ENV;
22 +
23 +var invariant = function(condition, format, a, b, c, d, e, f) {
24 + if (NODE_ENV !== 'production') {
25 + if (format === undefined) {
26 + throw new Error('invariant requires an error message argument');
27 + }
28 + }
29 +
30 + if (!condition) {
31 + var error;
32 + if (format === undefined) {
33 + error = new Error(
34 + 'Minified exception occurred; use the non-minified dev environment ' +
35 + 'for the full error message and additional helpful warnings.'
36 + );
37 + } else {
38 + var args = [a, b, c, d, e, f];
39 + var argIndex = 0;
40 + error = new Error(
41 + format.replace(/%s/g, function() { return args[argIndex++]; })
42 + );
43 + error.name = 'Invariant Violation';
44 + }
45 +
46 + error.framesToPop = 1; // we don't care about invariant's own frame
47 + throw error;
48 + }
49 +};
50 +
51 +module.exports = invariant;
1 +/* @flow strict */
2 +
3 +declare module.exports: (
4 + condition: any,
5 + format?: string,
6 + ...args: Array<any>
7 +) => void;
1 +{
2 + "_from": "invariant@^2.2.4",
3 + "_id": "invariant@2.2.4",
4 + "_inBundle": false,
5 + "_integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==",
6 + "_location": "/invariant",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "invariant@^2.2.4",
12 + "name": "invariant",
13 + "escapedName": "invariant",
14 + "rawSpec": "^2.2.4",
15 + "saveSpec": null,
16 + "fetchSpec": "^2.2.4"
17 + },
18 + "_requiredBy": [
19 + "/messaging-api-line"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz",
22 + "_shasum": "610f3c92c9359ce1db616e538008d23ff35158e6",
23 + "_spec": "invariant@^2.2.4",
24 + "_where": "C:\\Users\\김수민\\Desktop\\ostt\\LINEBOT\\node_modules\\messaging-api-line",
25 + "author": {
26 + "name": "Andres Suarez",
27 + "email": "zertosh@gmail.com"
28 + },
29 + "browser": "browser.js",
30 + "browserify": {
31 + "transform": [
32 + "loose-envify"
33 + ]
34 + },
35 + "bugs": {
36 + "url": "https://github.com/zertosh/invariant/issues"
37 + },
38 + "bundleDependencies": false,
39 + "dependencies": {
40 + "loose-envify": "^1.0.0"
41 + },
42 + "deprecated": false,
43 + "description": "invariant",
44 + "devDependencies": {
45 + "browserify": "^11.0.1",
46 + "flow-bin": "^0.67.1",
47 + "tap": "^1.4.0"
48 + },
49 + "files": [
50 + "browser.js",
51 + "invariant.js",
52 + "invariant.js.flow"
53 + ],
54 + "homepage": "https://github.com/zertosh/invariant#readme",
55 + "keywords": [
56 + "test",
57 + "invariant"
58 + ],
59 + "license": "MIT",
60 + "main": "invariant.js",
61 + "name": "invariant",
62 + "repository": {
63 + "type": "git",
64 + "url": "git+https://github.com/zertosh/invariant.git"
65 + },
66 + "scripts": {
67 + "test": "NODE_ENV=production tap test/*.js && NODE_ENV=development tap test/*.js"
68 + },
69 + "version": "2.2.4"
70 +}
1 +### Version 4.0.0 (2018-01-28) ###
2 +
3 +- Added: Support for ES2018. The only change needed was recognizing the `s`
4 + regex flag.
5 +- Changed: _All_ tokens returned by the `matchToToken` function now have a
6 + `closed` property. It is set to `undefined` for the tokens where “closed”
7 + doesn’t make sense. This means that all tokens objects have the same shape,
8 + which might improve performance.
9 +
10 +These are the breaking changes:
11 +
12 +- `'/a/s'.match(jsTokens)` no longer returns `['/', 'a', '/', 's']`, but
13 + `['/a/s']`. (There are of course other variations of this.)
14 +- Code that rely on some token objects not having the `closed` property could
15 + now behave differently.
16 +
17 +
18 +### Version 3.0.2 (2017-06-28) ###
19 +
20 +- No code changes. Just updates to the readme.
21 +
22 +
23 +### Version 3.0.1 (2017-01-30) ###
24 +
25 +- Fixed: ES2015 unicode escapes with more than 6 hex digits are now matched
26 + correctly.
27 +
28 +
29 +### Version 3.0.0 (2017-01-11) ###
30 +
31 +This release contains one breaking change, that should [improve performance in
32 +V8][v8-perf]:
33 +
34 +> So how can you, as a JavaScript developer, ensure that your RegExps are fast?
35 +> If you are not interested in hooking into RegExp internals, make sure that
36 +> neither the RegExp instance, nor its prototype is modified in order to get the
37 +> best performance:
38 +>
39 +> ```js
40 +> var re = /./g;
41 +> re.exec(''); // Fast path.
42 +> re.new_property = 'slow';
43 +> ```
44 +
45 +This module used to export a single regex, with `.matchToToken` bolted
46 +on, just like in the above example. This release changes the exports of
47 +the module to avoid this issue.
48 +
49 +Before:
50 +
51 +```js
52 +import jsTokens from "js-tokens"
53 +// or:
54 +var jsTokens = require("js-tokens")
55 +var matchToToken = jsTokens.matchToToken
56 +```
57 +
58 +After:
59 +
60 +```js
61 +import jsTokens, {matchToToken} from "js-tokens"
62 +// or:
63 +var jsTokens = require("js-tokens").default
64 +var matchToToken = require("js-tokens").matchToToken
65 +```
66 +
67 +[v8-perf]: http://v8project.blogspot.se/2017/01/speeding-up-v8-regular-expressions.html
68 +
69 +
70 +### Version 2.0.0 (2016-06-19) ###
71 +
72 +- Added: Support for ES2016. In other words, support for the `**` exponentiation
73 + operator.
74 +
75 +These are the breaking changes:
76 +
77 +- `'**'.match(jsTokens)` no longer returns `['*', '*']`, but `['**']`.
78 +- `'**='.match(jsTokens)` no longer returns `['*', '*=']`, but `['**=']`.
79 +
80 +
81 +### Version 1.0.3 (2016-03-27) ###
82 +
83 +- Improved: Made the regex ever so slightly smaller.
84 +- Updated: The readme.
85 +
86 +
87 +### Version 1.0.2 (2015-10-18) ###
88 +
89 +- Improved: Limited npm package contents for a smaller download. Thanks to
90 + @zertosh!
91 +
92 +
93 +### Version 1.0.1 (2015-06-20) ###
94 +
95 +- Fixed: Declared an undeclared variable.
96 +
97 +
98 +### Version 1.0.0 (2015-02-26) ###
99 +
100 +- Changed: Merged the 'operator' and 'punctuation' types into 'punctuator'. That
101 + type is now equivalent to the Punctuator token in the ECMAScript
102 + specification. (Backwards-incompatible change.)
103 +- Fixed: A `-` followed by a number is now correctly matched as a punctuator
104 + followed by a number. It used to be matched as just a number, but there is no
105 + such thing as negative number literals. (Possibly backwards-incompatible
106 + change.)
107 +
108 +
109 +### Version 0.4.1 (2015-02-21) ###
110 +
111 +- Added: Support for the regex `u` flag.
112 +
113 +
114 +### Version 0.4.0 (2015-02-21) ###
115 +
116 +- Improved: `jsTokens.matchToToken` performance.
117 +- Added: Support for octal and binary number literals.
118 +- Added: Support for template strings.
119 +
120 +
121 +### Version 0.3.1 (2015-01-06) ###
122 +
123 +- Fixed: Support for unicode spaces. They used to be allowed in names (which is
124 + very confusing), and some unicode newlines were wrongly allowed in strings and
125 + regexes.
126 +
127 +
128 +### Version 0.3.0 (2014-12-19) ###
129 +
130 +- Changed: The `jsTokens.names` array has been replaced with the
131 + `jsTokens.matchToToken` function. The capturing groups of `jsTokens` are no
132 + longer part of the public API; instead use said function. See this [gist] for
133 + an example. (Backwards-incompatible change.)
134 +- Changed: The empty string is now considered an “invalid” token, instead an
135 + “empty” token (its own group). (Backwards-incompatible change.)
136 +- Removed: component support. (Backwards-incompatible change.)
137 +
138 +[gist]: https://gist.github.com/lydell/be49dbf80c382c473004
139 +
140 +
141 +### Version 0.2.0 (2014-06-19) ###
142 +
143 +- Changed: Match ES6 function arrows (`=>`) as an operator, instead of its own
144 + category (“functionArrow”), for simplicity. (Backwards-incompatible change.)
145 +- Added: ES6 splats (`...`) are now matched as an operator (instead of three
146 + punctuations). (Backwards-incompatible change.)
147 +
148 +
149 +### Version 0.1.0 (2014-03-08) ###
150 +
151 +- Initial release.
1 +The MIT License (MIT)
2 +
3 +Copyright (c) 2014, 2015, 2016, 2017, 2018 Simon Lydell
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in
13 +all copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 +THE SOFTWARE.
1 +Overview [![Build Status](https://travis-ci.org/lydell/js-tokens.svg?branch=master)](https://travis-ci.org/lydell/js-tokens)
2 +========
3 +
4 +A regex that tokenizes JavaScript.
5 +
6 +```js
7 +var jsTokens = require("js-tokens").default
8 +
9 +var jsString = "var foo=opts.foo;\n..."
10 +
11 +jsString.match(jsTokens)
12 +// ["var", " ", "foo", "=", "opts", ".", "foo", ";", "\n", ...]
13 +```
14 +
15 +
16 +Installation
17 +============
18 +
19 +`npm install js-tokens`
20 +
21 +```js
22 +import jsTokens from "js-tokens"
23 +// or:
24 +var jsTokens = require("js-tokens").default
25 +```
26 +
27 +
28 +Usage
29 +=====
30 +
31 +### `jsTokens` ###
32 +
33 +A regex with the `g` flag that matches JavaScript tokens.
34 +
35 +The regex _always_ matches, even invalid JavaScript and the empty string.
36 +
37 +The next match is always directly after the previous.
38 +
39 +### `var token = matchToToken(match)` ###
40 +
41 +```js
42 +import {matchToToken} from "js-tokens"
43 +// or:
44 +var matchToToken = require("js-tokens").matchToToken
45 +```
46 +
47 +Takes a `match` returned by `jsTokens.exec(string)`, and returns a `{type:
48 +String, value: String}` object. The following types are available:
49 +
50 +- string
51 +- comment
52 +- regex
53 +- number
54 +- name
55 +- punctuator
56 +- whitespace
57 +- invalid
58 +
59 +Multi-line comments and strings also have a `closed` property indicating if the
60 +token was closed or not (see below).
61 +
62 +Comments and strings both come in several flavors. To distinguish them, check if
63 +the token starts with `//`, `/*`, `'`, `"` or `` ` ``.
64 +
65 +Names are ECMAScript IdentifierNames, that is, including both identifiers and
66 +keywords. You may use [is-keyword-js] to tell them apart.
67 +
68 +Whitespace includes both line terminators and other whitespace.
69 +
70 +[is-keyword-js]: https://github.com/crissdev/is-keyword-js
71 +
72 +
73 +ECMAScript support
74 +==================
75 +
76 +The intention is to always support the latest ECMAScript version whose feature
77 +set has been finalized.
78 +
79 +If adding support for a newer version requires changes, a new version with a
80 +major verion bump will be released.
81 +
82 +Currently, ECMAScript 2018 is supported.
83 +
84 +
85 +Invalid code handling
86 +=====================
87 +
88 +Unterminated strings are still matched as strings. JavaScript strings cannot
89 +contain (unescaped) newlines, so unterminated strings simply end at the end of
90 +the line. Unterminated template strings can contain unescaped newlines, though,
91 +so they go on to the end of input.
92 +
93 +Unterminated multi-line comments are also still matched as comments. They
94 +simply go on to the end of the input.
95 +
96 +Unterminated regex literals are likely matched as division and whatever is
97 +inside the regex.
98 +
99 +Invalid ASCII characters have their own capturing group.
100 +
101 +Invalid non-ASCII characters are treated as names, to simplify the matching of
102 +names (except unicode spaces which are treated as whitespace). Note: See also
103 +the [ES2018](#es2018) section.
104 +
105 +Regex literals may contain invalid regex syntax. They are still matched as
106 +regex literals. They may also contain repeated regex flags, to keep the regex
107 +simple.
108 +
109 +Strings may contain invalid escape sequences.
110 +
111 +
112 +Limitations
113 +===========
114 +
115 +Tokenizing JavaScript using regexes—in fact, _one single regex_—won’t be
116 +perfect. But that’s not the point either.
117 +
118 +You may compare jsTokens with [esprima] by using `esprima-compare.js`.
119 +See `npm run esprima-compare`!
120 +
121 +[esprima]: http://esprima.org/
122 +
123 +### Template string interpolation ###
124 +
125 +Template strings are matched as single tokens, from the starting `` ` `` to the
126 +ending `` ` ``, including interpolations (whose tokens are not matched
127 +individually).
128 +
129 +Matching template string interpolations requires recursive balancing of `{` and
130 +`}`—something that JavaScript regexes cannot do. Only one level of nesting is
131 +supported.
132 +
133 +### Division and regex literals collision ###
134 +
135 +Consider this example:
136 +
137 +```js
138 +var g = 9.82
139 +var number = bar / 2/g
140 +
141 +var regex = / 2/g
142 +```
143 +
144 +A human can easily understand that in the `number` line we’re dealing with
145 +division, and in the `regex` line we’re dealing with a regex literal. How come?
146 +Because humans can look at the whole code to put the `/` characters in context.
147 +A JavaScript regex cannot. It only sees forwards. (Well, ES2018 regexes can also
148 +look backwards. See the [ES2018](#es2018) section).
149 +
150 +When the `jsTokens` regex scans throught the above, it will see the following
151 +at the end of both the `number` and `regex` rows:
152 +
153 +```js
154 +/ 2/g
155 +```
156 +
157 +It is then impossible to know if that is a regex literal, or part of an
158 +expression dealing with division.
159 +
160 +Here is a similar case:
161 +
162 +```js
163 +foo /= 2/g
164 +foo(/= 2/g)
165 +```
166 +
167 +The first line divides the `foo` variable with `2/g`. The second line calls the
168 +`foo` function with the regex literal `/= 2/g`. Again, since `jsTokens` only
169 +sees forwards, it cannot tell the two cases apart.
170 +
171 +There are some cases where we _can_ tell division and regex literals apart,
172 +though.
173 +
174 +First off, we have the simple cases where there’s only one slash in the line:
175 +
176 +```js
177 +var foo = 2/g
178 +foo /= 2
179 +```
180 +
181 +Regex literals cannot contain newlines, so the above cases are correctly
182 +identified as division. Things are only problematic when there are more than
183 +one non-comment slash in a single line.
184 +
185 +Secondly, not every character is a valid regex flag.
186 +
187 +```js
188 +var number = bar / 2/e
189 +```
190 +
191 +The above example is also correctly identified as division, because `e` is not a
192 +valid regex flag. I initially wanted to future-proof by allowing `[a-zA-Z]*`
193 +(any letter) as flags, but it is not worth it since it increases the amount of
194 +ambigous cases. So only the standard `g`, `m`, `i`, `y` and `u` flags are
195 +allowed. This means that the above example will be identified as division as
196 +long as you don’t rename the `e` variable to some permutation of `gmiyus` 1 to 6
197 +characters long.
198 +
199 +Lastly, we can look _forward_ for information.
200 +
201 +- If the token following what looks like a regex literal is not valid after a
202 + regex literal, but is valid in a division expression, then the regex literal
203 + is treated as division instead. For example, a flagless regex cannot be
204 + followed by a string, number or name, but all of those three can be the
205 + denominator of a division.
206 +- Generally, if what looks like a regex literal is followed by an operator, the
207 + regex literal is treated as division instead. This is because regexes are
208 + seldomly used with operators (such as `+`, `*`, `&&` and `==`), but division
209 + could likely be part of such an expression.
210 +
211 +Please consult the regex source and the test cases for precise information on
212 +when regex or division is matched (should you need to know). In short, you
213 +could sum it up as:
214 +
215 +If the end of a statement looks like a regex literal (even if it isn’t), it
216 +will be treated as one. Otherwise it should work as expected (if you write sane
217 +code).
218 +
219 +### ES2018 ###
220 +
221 +ES2018 added some nice regex improvements to the language.
222 +
223 +- [Unicode property escapes] should allow telling names and invalid non-ASCII
224 + characters apart without blowing up the regex size.
225 +- [Lookbehind assertions] should allow matching telling division and regex
226 + literals apart in more cases.
227 +- [Named capture groups] might simplify some things.
228 +
229 +These things would be nice to do, but are not critical. They probably have to
230 +wait until the oldest maintained Node.js LTS release supports those features.
231 +
232 +[Unicode property escapes]: http://2ality.com/2017/07/regexp-unicode-property-escapes.html
233 +[Lookbehind assertions]: http://2ality.com/2017/05/regexp-lookbehind-assertions.html
234 +[Named capture groups]: http://2ality.com/2017/05/regexp-named-capture-groups.html
235 +
236 +
237 +License
238 +=======
239 +
240 +[MIT](LICENSE).
1 +// Copyright 2014, 2015, 2016, 2017, 2018 Simon Lydell
2 +// License: MIT. (See LICENSE.)
3 +
4 +Object.defineProperty(exports, "__esModule", {
5 + value: true
6 +})
7 +
8 +// This regex comes from regex.coffee, and is inserted here by generate-index.js
9 +// (run `npm run build`).
10 +exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g
11 +
12 +exports.matchToToken = function(match) {
13 + var token = {type: "invalid", value: match[0], closed: undefined}
14 + if (match[ 1]) token.type = "string" , token.closed = !!(match[3] || match[4])
15 + else if (match[ 5]) token.type = "comment"
16 + else if (match[ 6]) token.type = "comment", token.closed = !!match[7]
17 + else if (match[ 8]) token.type = "regex"
18 + else if (match[ 9]) token.type = "number"
19 + else if (match[10]) token.type = "name"
20 + else if (match[11]) token.type = "punctuator"
21 + else if (match[12]) token.type = "whitespace"
22 + return token
23 +}
1 +{
2 + "_from": "js-tokens@^3.0.0 || ^4.0.0",
3 + "_id": "js-tokens@4.0.0",
4 + "_inBundle": false,
5 + "_integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
6 + "_location": "/js-tokens",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "js-tokens@^3.0.0 || ^4.0.0",
12 + "name": "js-tokens",
13 + "escapedName": "js-tokens",
14 + "rawSpec": "^3.0.0 || ^4.0.0",
15 + "saveSpec": null,
16 + "fetchSpec": "^3.0.0 || ^4.0.0"
17 + },
18 + "_requiredBy": [
19 + "/loose-envify"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
22 + "_shasum": "19203fb59991df98e3a287050d4647cdeaf32499",
23 + "_spec": "js-tokens@^3.0.0 || ^4.0.0",
24 + "_where": "C:\\Users\\김수민\\Desktop\\ostt\\LINEBOT\\node_modules\\loose-envify",
25 + "author": {
26 + "name": "Simon Lydell"
27 + },
28 + "bugs": {
29 + "url": "https://github.com/lydell/js-tokens/issues"
30 + },
31 + "bundleDependencies": false,
32 + "deprecated": false,
33 + "description": "A regex that tokenizes JavaScript.",
34 + "devDependencies": {
35 + "coffeescript": "2.1.1",
36 + "esprima": "4.0.0",
37 + "everything.js": "1.0.3",
38 + "mocha": "5.0.0"
39 + },
40 + "files": [
41 + "index.js"
42 + ],
43 + "homepage": "https://github.com/lydell/js-tokens#readme",
44 + "keywords": [
45 + "JavaScript",
46 + "js",
47 + "token",
48 + "tokenize",
49 + "regex"
50 + ],
51 + "license": "MIT",
52 + "name": "js-tokens",
53 + "repository": {
54 + "type": "git",
55 + "url": "git+https://github.com/lydell/js-tokens.git"
56 + },
57 + "scripts": {
58 + "build": "node generate-index.js",
59 + "dev": "npm run build && npm test",
60 + "esprima-compare": "node esprima-compare ./index.js everything.js/es5.js",
61 + "test": "mocha --ui tdd"
62 + },
63 + "version": "4.0.0"
64 +}
1 +Copyright jQuery Foundation and other contributors <https://jquery.org/>
2 +
3 +Based on Underscore.js, copyright Jeremy Ashkenas,
4 +DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
5 +
6 +This software consists of voluntary contributions made by many
7 +individuals. For exact contribution history, see the revision history
8 +available at https://github.com/lodash/lodash
9 +
10 +The following license applies to all parts of this software except as
11 +documented below:
12 +
13 +====
14 +
15 +Permission is hereby granted, free of charge, to any person obtaining
16 +a copy of this software and associated documentation files (the
17 +"Software"), to deal in the Software without restriction, including
18 +without limitation the rights to use, copy, modify, merge, publish,
19 +distribute, sublicense, and/or sell copies of the Software, and to
20 +permit persons to whom the Software is furnished to do so, subject to
21 +the following conditions:
22 +
23 +The above copyright notice and this permission notice shall be
24 +included in all copies or substantial portions of the Software.
25 +
26 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 +
34 +====
35 +
36 +Copyright and related rights for sample code are waived via CC0. Sample
37 +code is defined as all source code displayed within the prose of the
38 +documentation.
39 +
40 +CC0: http://creativecommons.org/publicdomain/zero/1.0/
41 +
42 +====
43 +
44 +Files located in the node_modules and vendor directories are externally
45 +maintained libraries used by this software which have their own
46 +licenses; we recommend you read them, as their terms may differ from the
47 +terms above.
1 +# lodash.omit v4.5.0
2 +
3 +The [lodash](https://lodash.com/) method `_.omit` exported as a [Node.js](https://nodejs.org/) module.
4 +
5 +## Installation
6 +
7 +Using npm:
8 +```bash
9 +$ {sudo -H} npm i -g npm
10 +$ npm i --save lodash.omit
11 +```
12 +
13 +In Node.js:
14 +```js
15 +var omit = require('lodash.omit');
16 +```
17 +
18 +See the [documentation](https://lodash.com/docs#omit) or [package source](https://github.com/lodash/lodash/blob/4.5.0-npm-packages/lodash.omit) for more details.
This diff is collapsed. Click to expand it.
1 +{
2 + "_from": "lodash.omit@^4.5.0",
3 + "_id": "lodash.omit@4.5.0",
4 + "_inBundle": false,
5 + "_integrity": "sha1-brGa5aHuHdnfC5aeZs4Lf6MLXmA=",
6 + "_location": "/lodash.omit",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "lodash.omit@^4.5.0",
12 + "name": "lodash.omit",
13 + "escapedName": "lodash.omit",
14 + "rawSpec": "^4.5.0",
15 + "saveSpec": null,
16 + "fetchSpec": "^4.5.0"
17 + },
18 + "_requiredBy": [
19 + "/messaging-api-line"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/lodash.omit/-/lodash.omit-4.5.0.tgz",
22 + "_shasum": "6eb19ae5a1ee1dd9df0b969e66ce0b7fa30b5e60",
23 + "_spec": "lodash.omit@^4.5.0",
24 + "_where": "C:\\Users\\김수민\\Desktop\\ostt\\LINEBOT\\node_modules\\messaging-api-line",
25 + "author": {
26 + "name": "John-David Dalton",
27 + "email": "john.david.dalton@gmail.com",
28 + "url": "http://allyoucanleet.com/"
29 + },
30 + "bugs": {
31 + "url": "https://github.com/lodash/lodash/issues"
32 + },
33 + "bundleDependencies": false,
34 + "contributors": [
35 + {
36 + "name": "John-David Dalton",
37 + "email": "john.david.dalton@gmail.com",
38 + "url": "http://allyoucanleet.com/"
39 + },
40 + {
41 + "name": "Blaine Bublitz",
42 + "email": "blaine.bublitz@gmail.com",
43 + "url": "https://github.com/phated"
44 + },
45 + {
46 + "name": "Mathias Bynens",
47 + "email": "mathias@qiwi.be",
48 + "url": "https://mathiasbynens.be/"
49 + }
50 + ],
51 + "deprecated": false,
52 + "description": "The lodash method `_.omit` exported as a module.",
53 + "homepage": "https://lodash.com/",
54 + "icon": "https://lodash.com/icon.svg",
55 + "keywords": [
56 + "lodash-modularized",
57 + "omit"
58 + ],
59 + "license": "MIT",
60 + "name": "lodash.omit",
61 + "repository": {
62 + "type": "git",
63 + "url": "git+https://github.com/lodash/lodash.git"
64 + },
65 + "scripts": {
66 + "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\""
67 + },
68 + "version": "4.5.0"
69 +}
1 +The MIT License (MIT)
2 +
3 +Copyright (c) 2015 Andres Suarez <zertosh@gmail.com>
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in
13 +all copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 +THE SOFTWARE.
1 +# loose-envify
2 +
3 +[![Build Status](https://travis-ci.org/zertosh/loose-envify.svg?branch=master)](https://travis-ci.org/zertosh/loose-envify)
4 +
5 +Fast (and loose) selective `process.env` replacer using [js-tokens](https://github.com/lydell/js-tokens) instead of an AST. Works just like [envify](https://github.com/hughsk/envify) but much faster.
6 +
7 +## Gotchas
8 +
9 +* Doesn't handle broken syntax.
10 +* Doesn't look inside embedded expressions in template strings.
11 + - **this won't work:**
12 + ```js
13 + console.log(`the current env is ${process.env.NODE_ENV}`);
14 + ```
15 +* Doesn't replace oddly-spaced or oddly-commented expressions.
16 + - **this won't work:**
17 + ```js
18 + console.log(process./*won't*/env./*work*/NODE_ENV);
19 + ```
20 +
21 +## Usage/Options
22 +
23 +loose-envify has the exact same interface as [envify](https://github.com/hughsk/envify), including the CLI.
24 +
25 +## Benchmark
26 +
27 +```
28 +envify:
29 +
30 + $ for i in {1..5}; do node bench/bench.js 'envify'; done
31 + 708ms
32 + 727ms
33 + 791ms
34 + 719ms
35 + 720ms
36 +
37 +loose-envify:
38 +
39 + $ for i in {1..5}; do node bench/bench.js '../'; done
40 + 51ms
41 + 52ms
42 + 52ms
43 + 52ms
44 + 52ms
45 +```
1 +#!/usr/bin/env node
2 +'use strict';
3 +
4 +var looseEnvify = require('./');
5 +var fs = require('fs');
6 +
7 +if (process.argv[2]) {
8 + fs.createReadStream(process.argv[2], {encoding: 'utf8'})
9 + .pipe(looseEnvify(process.argv[2]))
10 + .pipe(process.stdout);
11 +} else {
12 + process.stdin.resume()
13 + process.stdin
14 + .pipe(looseEnvify(__filename))
15 + .pipe(process.stdout);
16 +}
1 +// envify compatibility
2 +'use strict';
3 +
4 +module.exports = require('./loose-envify');
1 +'use strict';
2 +
3 +module.exports = require('./loose-envify')(process.env);
1 +'use strict';
2 +
3 +var stream = require('stream');
4 +var util = require('util');
5 +var replace = require('./replace');
6 +
7 +var jsonExtRe = /\.json$/;
8 +
9 +module.exports = function(rootEnv) {
10 + rootEnv = rootEnv || process.env;
11 + return function (file, trOpts) {
12 + if (jsonExtRe.test(file)) {
13 + return stream.PassThrough();
14 + }
15 + var envs = trOpts ? [rootEnv, trOpts] : [rootEnv];
16 + return new LooseEnvify(envs);
17 + };
18 +};
19 +
20 +function LooseEnvify(envs) {
21 + stream.Transform.call(this);
22 + this._data = '';
23 + this._envs = envs;
24 +}
25 +util.inherits(LooseEnvify, stream.Transform);
26 +
27 +LooseEnvify.prototype._transform = function(buf, enc, cb) {
28 + this._data += buf;
29 + cb();
30 +};
31 +
32 +LooseEnvify.prototype._flush = function(cb) {
33 + var replaced = replace(this._data, this._envs);
34 + this.push(replaced);
35 + cb();
36 +};
1 +{
2 + "_from": "loose-envify@^1.0.0",
3 + "_id": "loose-envify@1.4.0",
4 + "_inBundle": false,
5 + "_integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
6 + "_location": "/loose-envify",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "loose-envify@^1.0.0",
12 + "name": "loose-envify",
13 + "escapedName": "loose-envify",
14 + "rawSpec": "^1.0.0",
15 + "saveSpec": null,
16 + "fetchSpec": "^1.0.0"
17 + },
18 + "_requiredBy": [
19 + "/invariant"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
22 + "_shasum": "71ee51fa7be4caec1a63839f7e682d8132d30caf",
23 + "_spec": "loose-envify@^1.0.0",
24 + "_where": "C:\\Users\\김수민\\Desktop\\ostt\\LINEBOT\\node_modules\\invariant",
25 + "author": {
26 + "name": "Andres Suarez",
27 + "email": "zertosh@gmail.com"
28 + },
29 + "bin": {
30 + "loose-envify": "cli.js"
31 + },
32 + "bugs": {
33 + "url": "https://github.com/zertosh/loose-envify/issues"
34 + },
35 + "bundleDependencies": false,
36 + "dependencies": {
37 + "js-tokens": "^3.0.0 || ^4.0.0"
38 + },
39 + "deprecated": false,
40 + "description": "Fast (and loose) selective `process.env` replacer using js-tokens instead of an AST",
41 + "devDependencies": {
42 + "browserify": "^13.1.1",
43 + "envify": "^3.4.0",
44 + "tap": "^8.0.0"
45 + },
46 + "homepage": "https://github.com/zertosh/loose-envify",
47 + "keywords": [
48 + "environment",
49 + "variables",
50 + "browserify",
51 + "browserify-transform",
52 + "transform",
53 + "source",
54 + "configuration"
55 + ],
56 + "license": "MIT",
57 + "main": "index.js",
58 + "name": "loose-envify",
59 + "repository": {
60 + "type": "git",
61 + "url": "git://github.com/zertosh/loose-envify.git"
62 + },
63 + "scripts": {
64 + "test": "tap test/*.js"
65 + },
66 + "version": "1.4.0"
67 +}
1 +'use strict';
2 +
3 +var jsTokens = require('js-tokens').default;
4 +
5 +var processEnvRe = /\bprocess\.env\.[_$a-zA-Z][$\w]+\b/;
6 +var spaceOrCommentRe = /^(?:\s|\/[/*])/;
7 +
8 +function replace(src, envs) {
9 + if (!processEnvRe.test(src)) {
10 + return src;
11 + }
12 +
13 + var out = [];
14 + var purge = envs.some(function(env) {
15 + return env._ && env._.indexOf('purge') !== -1;
16 + });
17 +
18 + jsTokens.lastIndex = 0
19 + var parts = src.match(jsTokens);
20 +
21 + for (var i = 0; i < parts.length; i++) {
22 + if (parts[i ] === 'process' &&
23 + parts[i + 1] === '.' &&
24 + parts[i + 2] === 'env' &&
25 + parts[i + 3] === '.') {
26 + var prevCodeToken = getAdjacentCodeToken(-1, parts, i);
27 + var nextCodeToken = getAdjacentCodeToken(1, parts, i + 4);
28 + var replacement = getReplacementString(envs, parts[i + 4], purge);
29 + if (prevCodeToken !== '.' &&
30 + nextCodeToken !== '.' &&
31 + nextCodeToken !== '=' &&
32 + typeof replacement === 'string') {
33 + out.push(replacement);
34 + i += 4;
35 + continue;
36 + }
37 + }
38 + out.push(parts[i]);
39 + }
40 +
41 + return out.join('');
42 +}
43 +
44 +function getAdjacentCodeToken(dir, parts, i) {
45 + while (true) {
46 + var part = parts[i += dir];
47 + if (!spaceOrCommentRe.test(part)) {
48 + return part;
49 + }
50 + }
51 +}
52 +
53 +function getReplacementString(envs, name, purge) {
54 + for (var j = 0; j < envs.length; j++) {
55 + var env = envs[j];
56 + if (typeof env[name] !== 'undefined') {
57 + return JSON.stringify(env[name]);
58 + }
59 + }
60 + if (purge) {
61 + return 'undefined';
62 + }
63 +}
64 +
65 +module.exports = replace;
1 +The MIT License (MIT)
2 +
3 +Copyright (c) 2017-present Yoctol (github.com/Yoctol/messaging-apis)
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in
13 +all copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 +THE SOFTWARE.
This diff could not be displayed because it is too large.
1 +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0;
2 +var _invariant = _interopRequireDefault(require("invariant"));
3 +var _lodash = _interopRequireDefault(require("lodash.omit"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function ownKeys(object, enumerableOnly) {var keys = Object.keys(object);if (Object.getOwnPropertySymbols) {var symbols = Object.getOwnPropertySymbols(object);if (enumerableOnly) symbols = symbols.filter(function (sym) {return Object.getOwnPropertyDescriptor(object, sym).enumerable;});keys.push.apply(keys, symbols);}return keys;}function _objectSpread(target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {ownKeys(source, true).forEach(function (key) {_defineProperty(target, key, source[key]);});} else if (Object.getOwnPropertyDescriptors) {Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));} else {ownKeys(source).forEach(function (key) {Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));});}}return target;}function _defineProperty(obj, key, value) {if (key in obj) {Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });} else {obj[key] = value;}return obj;}
4 +
5 +
6 +
7 +
8 +
9 +
10 +
11 +
12 +
13 +
14 +
15 +
16 +
17 +
18 +
19 +
20 +
21 +
22 +
23 +
24 +
25 +
26 +
27 +
28 +
29 +
30 +
31 +function createText(text, options = {}) {
32 + return _objectSpread({
33 + type: 'text',
34 + text },
35 + (0, _lodash.default)(options, 'accessToken'));
36 +
37 +}
38 +
39 +function createImage(
40 +contentUrlOrImage,
41 +previewUrlOrOptions)
42 +{
43 + if (previewUrlOrOptions) {
44 + if (
45 + typeof contentUrlOrImage === 'object' &&
46 + typeof previewUrlOrOptions === 'object')
47 + {
48 + const image = contentUrlOrImage;
49 + const options = previewUrlOrOptions;
50 + return _objectSpread({
51 + type: 'image',
52 + originalContentUrl: image.originalContentUrl,
53 + previewImageUrl: image.previewImageUrl || image.originalContentUrl },
54 + (0, _lodash.default)(options, 'accessToken'));
55 +
56 + }
57 +
58 + if (
59 + typeof contentUrlOrImage === 'string' &&
60 + typeof previewUrlOrOptions === 'string')
61 + {
62 + return {
63 + type: 'image',
64 + originalContentUrl: contentUrlOrImage,
65 + previewImageUrl: previewUrlOrOptions };
66 +
67 + }
68 + } else {
69 + if (typeof contentUrlOrImage === 'object') {
70 + const image = contentUrlOrImage;
71 + return {
72 + type: 'image',
73 + originalContentUrl: image.originalContentUrl,
74 + previewImageUrl: image.previewImageUrl || image.originalContentUrl };
75 +
76 + }
77 +
78 + if (typeof contentUrlOrImage === 'string') {
79 + return {
80 + type: 'image',
81 + originalContentUrl: contentUrlOrImage,
82 + previewImageUrl: contentUrlOrImage };
83 +
84 + }
85 + }
86 +
87 + (0, _invariant.default)(false, 'Line#createImage: Wrong type of arguments.');
88 +}
89 +
90 +function createVideo(
91 +contentUrlOrVideo,
92 +previewImageUrlOrOptions)
93 +{
94 + if (
95 + typeof contentUrlOrVideo === 'string' &&
96 + typeof previewImageUrlOrOptions === 'string')
97 + {
98 + return {
99 + type: 'video',
100 + originalContentUrl: contentUrlOrVideo,
101 + previewImageUrl: previewImageUrlOrOptions };
102 +
103 + }
104 +
105 + if (
106 + typeof contentUrlOrVideo === 'object' && (
107 + !previewImageUrlOrOptions || typeof previewImageUrlOrOptions === 'object'))
108 + {
109 + const video = contentUrlOrVideo;
110 + const options = previewImageUrlOrOptions || {};
111 + return _objectSpread({
112 + type: 'video',
113 + originalContentUrl: video.originalContentUrl,
114 + previewImageUrl: video.previewImageUrl },
115 + (0, _lodash.default)(options, 'accessToken'));
116 +
117 + }
118 +
119 + (0, _invariant.default)(false, 'Line#createVideo: Wrong type of arguments.');
120 +}
121 +
122 +function createAudio(
123 +contentUrlOrAudio,
124 +durationOrOptions)
125 +{
126 + if (
127 + typeof contentUrlOrAudio === 'string' &&
128 + typeof durationOrOptions === 'number')
129 + {
130 + return {
131 + type: 'audio',
132 + originalContentUrl: contentUrlOrAudio,
133 + duration: durationOrOptions };
134 +
135 + }
136 +
137 + if (
138 + typeof contentUrlOrAudio === 'object' && (
139 + !durationOrOptions || typeof durationOrOptions === 'object'))
140 + {
141 + const audio = contentUrlOrAudio;
142 + const options = durationOrOptions || {};
143 + return _objectSpread({
144 + type: 'audio',
145 + originalContentUrl: audio.originalContentUrl,
146 + duration: audio.duration },
147 + (0, _lodash.default)(options, 'accessToken'));
148 +
149 + }
150 +
151 + (0, _invariant.default)(false, 'Line#createAudio: Wrong type of arguments.');
152 +}
153 +
154 +function createLocation(
155 +{ title, address, latitude, longitude },
156 +options = {})
157 +{
158 + return _objectSpread({
159 + type: 'location',
160 + title,
161 + address,
162 + latitude,
163 + longitude },
164 + (0, _lodash.default)(options, 'accessToken'));
165 +
166 +}
167 +
168 +function createSticker(
169 +packageIdOrSticker,
170 +stickerIdOrOptions)
171 +{
172 + if (
173 + typeof packageIdOrSticker === 'string' &&
174 + typeof stickerIdOrOptions === 'string')
175 + {
176 + return {
177 + type: 'sticker',
178 + packageId: packageIdOrSticker,
179 + stickerId: stickerIdOrOptions };
180 +
181 + }
182 +
183 + if (
184 + typeof packageIdOrSticker === 'object' && (
185 + !stickerIdOrOptions || typeof stickerIdOrOptions === 'object'))
186 + {
187 + const sticker = packageIdOrSticker;
188 + const options = stickerIdOrOptions || {};
189 + return _objectSpread({
190 + type: 'sticker',
191 + packageId: sticker.packageId,
192 + stickerId: sticker.stickerId },
193 + (0, _lodash.default)(options, 'accessToken'));
194 +
195 + }
196 +
197 + (0, _invariant.default)(false, 'Line#createSticker: Wrong type of arguments.');
198 +}
199 +
200 +function createImagemap(
201 +altText,
202 +{
203 + baseUrl,
204 + baseSize,
205 + baseHeight,
206 + baseWidth,
207 + video,
208 + actions },
209 +
210 +
211 +
212 +
213 +
214 +
215 +
216 +
217 +
218 +
219 +
220 +options = {})
221 +{
222 + return _objectSpread({
223 + type: 'imagemap',
224 + baseUrl,
225 + altText,
226 + baseSize: baseSize || {
227 + height: baseHeight,
228 + width: baseWidth },
229 +
230 + video,
231 + actions },
232 + (0, _lodash.default)(options, 'accessToken'));
233 +
234 +}
235 +
236 +function createTemplate(
237 +altText,
238 +template,
239 +options = {})
240 +{
241 + return _objectSpread({
242 + type: 'template',
243 + altText,
244 + template },
245 + (0, _lodash.default)(options, 'accessToken'));
246 +
247 +}
248 +
249 +function createButtonTemplate(
250 +altText,
251 +{
252 + thumbnailImageUrl,
253 + imageAspectRatio,
254 + imageSize,
255 + imageBackgroundColor,
256 + title,
257 + text,
258 + defaultAction,
259 + actions },
260 +
261 +
262 +
263 +
264 +
265 +
266 +
267 +
268 +
269 +
270 +options = {})
271 +{
272 + return createTemplate(
273 + altText,
274 + {
275 + type: 'buttons',
276 + thumbnailImageUrl,
277 + imageAspectRatio,
278 + imageSize,
279 + imageBackgroundColor,
280 + title,
281 + text,
282 + defaultAction,
283 + actions },
284 +
285 + (0, _lodash.default)(options, 'accessToken'));
286 +
287 +}
288 +
289 +function createConfirmTemplate(
290 +altText,
291 +{
292 + text,
293 + actions },
294 +
295 +
296 +
297 +
298 +options = {})
299 +{
300 + return createTemplate(
301 + altText,
302 + {
303 + type: 'confirm',
304 + text,
305 + actions },
306 +
307 + (0, _lodash.default)(options, 'accessToken'));
308 +
309 +}
310 +
311 +function createCarouselTemplate(
312 +altText,
313 +columns,
314 +{
315 + imageAspectRatio,
316 + imageSize,
317 + quickReply } =
318 +
319 +
320 +
321 +
322 +{})
323 +{
324 + return createTemplate(
325 + altText,
326 + {
327 + type: 'carousel',
328 + columns,
329 + imageAspectRatio,
330 + imageSize },
331 +
332 + { quickReply });
333 +
334 +}
335 +
336 +function createImageCarouselTemplate(
337 +altText,
338 +columns,
339 +options = {})
340 +{
341 + return createTemplate(
342 + altText,
343 + {
344 + type: 'image_carousel',
345 + columns },
346 +
347 + (0, _lodash.default)(options, 'accessToken'));
348 +
349 +}
350 +
351 +function createFlex(
352 +altText,
353 +contents,
354 +options = {})
355 +{
356 + return _objectSpread({
357 + type: 'flex',
358 + altText,
359 + contents },
360 + (0, _lodash.default)(options, 'accessToken'));
361 +
362 +}
363 +
364 +const Line = {
365 + createText,
366 + createImage,
367 + createVideo,
368 + createAudio,
369 + createLocation,
370 + createSticker,
371 + createImagemap,
372 + createTemplate,
373 + createButtonsTemplate: createButtonTemplate,
374 + createButtonTemplate,
375 + createConfirmTemplate,
376 + createCarouselTemplate,
377 + createImageCarouselTemplate,
378 + createFlex };var _default =
379 +
380 +
381 +Line;exports.default = _default;
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
1 +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0;
2 +var _querystring = _interopRequireDefault(require("querystring"));
3 +
4 +var _axiosError = _interopRequireDefault(require("axios-error"));
5 +var _axios = _interopRequireDefault(require("axios"));
6 +var _invariant = _interopRequireDefault(require("invariant"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function ownKeys(object, enumerableOnly) {var keys = Object.keys(object);if (Object.getOwnPropertySymbols) {var symbols = Object.getOwnPropertySymbols(object);if (enumerableOnly) symbols = symbols.filter(function (sym) {return Object.getOwnPropertyDescriptor(object, sym).enumerable;});keys.push.apply(keys, symbols);}return keys;}function _objectSpread(target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {ownKeys(source, true).forEach(function (key) {_defineProperty(target, key, source[key]);});} else if (Object.getOwnPropertyDescriptors) {Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));} else {ownKeys(source).forEach(function (key) {Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));});}}return target;}function _objectWithoutProperties(source, excluded) {if (source == null) return {};var target = _objectWithoutPropertiesLoose(source, excluded);var key, i;if (Object.getOwnPropertySymbols) {var sourceSymbolKeys = Object.getOwnPropertySymbols(source);for (i = 0; i < sourceSymbolKeys.length; i++) {key = sourceSymbolKeys[i];if (excluded.indexOf(key) >= 0) continue;if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;target[key] = source[key];}}return target;}function _objectWithoutPropertiesLoose(source, excluded) {if (source == null) return {};var target = {};var sourceKeys = Object.keys(source);var key, i;for (i = 0; i < sourceKeys.length; i++) {key = sourceKeys[i];if (excluded.indexOf(key) >= 0) continue;target[key] = source[key];}return target;}function _defineProperty(obj, key, value) {if (key in obj) {Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });} else {obj[key] = value;}return obj;}
7 +
8 +
9 +
10 +
11 +
12 +
13 +
14 +
15 +
16 +
17 +
18 +
19 +
20 +
21 +
22 +
23 +
24 +
25 +function handleError(err) {
26 + if (err.response && err.response.data) {
27 + const { returnCode, returnMessage } = err.response.data;
28 + const msg = `LINE PAY API - ${returnCode} ${returnMessage}`;
29 + throw new _axiosError.default(msg, err);
30 + }
31 + throw new _axiosError.default(err.message, err);
32 +}
33 +
34 +function throwWhenNotSuccess(res) {
35 + if (res.data.returnCode !== '0000') {
36 + const { returnCode, returnMessage } = res.data;
37 + const msg = `LINE PAY API - ${returnCode} ${returnMessage}`;
38 + throw new _axiosError.default(msg);
39 + }
40 + return res.data.info;
41 +}
42 +
43 +class LinePay {
44 + static connect(config) {
45 + return new LinePay(config);
46 + }
47 +
48 +
49 +
50 + constructor({
51 + channelId,
52 + channelSecret,
53 + sandbox = false,
54 + origin })
55 + {_defineProperty(this, "_axios", void 0);
56 + const linePayOrigin = sandbox ?
57 + 'https://sandbox-api-pay.line.me' :
58 + 'https://api-pay.line.me';
59 +
60 + this._axios = _axios.default.create({
61 + baseURL: `${origin || linePayOrigin}/v2/`,
62 + headers: {
63 + 'Content-Type': 'application/json',
64 + 'X-LINE-ChannelId': channelId,
65 + 'X-LINE-ChannelSecret': channelSecret } });
66 +
67 +
68 + }
69 +
70 + get axios() {
71 + return this._axios;
72 + }
73 +
74 + getPayments({
75 + transactionId,
76 + orderId } =
77 +
78 +
79 +
80 + {}) {
81 + (0, _invariant.default)(
82 + transactionId || orderId,
83 + 'getPayments: One of `transactionId` or `orderId` must be provided');
84 +
85 +
86 + const query = {};
87 +
88 + if (transactionId) {
89 + query.transactionId = transactionId;
90 + }
91 +
92 + if (orderId) {
93 + query.orderId = orderId;
94 + }
95 +
96 + return this._axios.
97 + get(`/payments?${_querystring.default.stringify(query)}`).
98 + then(throwWhenNotSuccess, handleError);
99 + }
100 +
101 + getAuthorizations({
102 + transactionId,
103 + orderId } =
104 +
105 +
106 +
107 + {}) {
108 + (0, _invariant.default)(
109 + transactionId || orderId,
110 + 'getAuthorizations: One of `transactionId` or `orderId` must be provided');
111 +
112 +
113 + const query = {};
114 +
115 + if (transactionId) {
116 + query.transactionId = transactionId;
117 + }
118 +
119 + if (orderId) {
120 + query.orderId = orderId;
121 + }
122 +
123 + return this._axios.
124 + get(`/payments/authorizations?${_querystring.default.stringify(query)}`).
125 + then(throwWhenNotSuccess, handleError);
126 + }
127 +
128 + reserve(_ref)
129 +
130 +
131 +
132 +
133 +
134 +
135 +
136 +
137 +
138 +
139 +
140 +
141 +
142 +
143 +
144 +
145 +
146 +
147 +
148 +
149 +
150 +
151 +
152 +
153 + {let { productName, amount, currency, confirmUrl, orderId } = _ref,options = _objectWithoutProperties(_ref, ["productName", "amount", "currency", "confirmUrl", "orderId"]);
154 + return this._axios.
155 + post('/payments/request', _objectSpread({
156 + productName,
157 + amount,
158 + currency,
159 + confirmUrl,
160 + orderId },
161 + options)).
162 +
163 + then(throwWhenNotSuccess, handleError);
164 + }
165 +
166 + confirm(
167 + transactionId,
168 + {
169 + amount,
170 + currency })
171 +
172 +
173 +
174 +
175 + {
176 + return this._axios.
177 + post(`/payments/${transactionId}/confirm`, {
178 + amount,
179 + currency }).
180 +
181 + then(throwWhenNotSuccess, handleError);
182 + }
183 +
184 + capture(
185 + transactionId,
186 + {
187 + amount,
188 + currency })
189 +
190 +
191 +
192 +
193 + {
194 + return this._axios.
195 + post(`/payments/authorizations/${transactionId}/capture`, {
196 + amount,
197 + currency }).
198 +
199 + then(throwWhenNotSuccess, handleError);
200 + }
201 +
202 + void(transactionId) {
203 + return this._axios.
204 + post(`/payments/authorizations/${transactionId}/void`).
205 + then(throwWhenNotSuccess, handleError);
206 + }
207 +
208 + refund(transactionId, options = {}) {
209 + return this._axios.
210 + post(`/payments/${transactionId}/refund`, options).
211 + then(throwWhenNotSuccess, handleError);
212 + }}exports.default = LinePay;
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";Object.defineProperty(exports, "__esModule", { value: true });Object.defineProperty(exports, "Line", { enumerable: true, get: function () {return _Line.default;} });exports.default = void 0;
2 +
3 +var _Line = _interopRequireDefault(require("./Line"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}var _default =
4 +
5 +
6 +{ Line: _Line.default };exports.default = _default;
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";Object.defineProperty(exports, "__esModule", { value: true });Object.defineProperty(exports, "Line", { enumerable: true, get: function () {return _Line.default;} });Object.defineProperty(exports, "LineClient", { enumerable: true, get: function () {return _LineClient.default;} });Object.defineProperty(exports, "LinePay", { enumerable: true, get: function () {return _LinePay.default;} });exports.default = void 0;
2 +
3 +var _Line = _interopRequireDefault(require("./Line"));
4 +var _LineClient = _interopRequireDefault(require("./LineClient"));
5 +var _LinePay = _interopRequireDefault(require("./LinePay"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}var _default =
6 +
7 +
8 +{ Line: _Line.default, LineClient: _LineClient.default, LinePay: _LinePay.default };exports.default = _default;
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
1 +(The MIT License)
2 +
3 +Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca>
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy of this software
6 +and associated documentation files (the 'Software'), to deal in the Software without restriction,
7 +including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 +and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
9 +subject to the following conditions:
10 +
11 +The above copyright notice and this permission notice shall be included in all copies or substantial
12 +portions of the Software.
13 +
14 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15 +LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17 +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
18 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 +
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 +{
2 + "_from": "debug@^4.1.1",
3 + "_id": "debug@4.1.1",
4 + "_inBundle": false,
5 + "_integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
6 + "_location": "/messaging-api-line/debug",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "debug@^4.1.1",
12 + "name": "debug",
13 + "escapedName": "debug",
14 + "rawSpec": "^4.1.1",
15 + "saveSpec": null,
16 + "fetchSpec": "^4.1.1"
17 + },
18 + "_requiredBy": [
19 + "/messaging-api-line"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
22 + "_shasum": "3b72260255109c6b589cee050f1d516139664791",
23 + "_spec": "debug@^4.1.1",
24 + "_where": "C:\\Users\\김수민\\Desktop\\ostt\\LINEBOT\\node_modules\\messaging-api-line",
25 + "author": {
26 + "name": "TJ Holowaychuk",
27 + "email": "tj@vision-media.ca"
28 + },
29 + "browser": "./src/browser.js",
30 + "bugs": {
31 + "url": "https://github.com/visionmedia/debug/issues"
32 + },
33 + "bundleDependencies": false,
34 + "contributors": [
35 + {
36 + "name": "Nathan Rajlich",
37 + "email": "nathan@tootallnate.net",
38 + "url": "http://n8.io"
39 + },
40 + {
41 + "name": "Andrew Rhyne",
42 + "email": "rhyneandrew@gmail.com"
43 + }
44 + ],
45 + "dependencies": {
46 + "ms": "^2.1.1"
47 + },
48 + "deprecated": false,
49 + "description": "small debugging utility",
50 + "devDependencies": {
51 + "@babel/cli": "^7.0.0",
52 + "@babel/core": "^7.0.0",
53 + "@babel/preset-env": "^7.0.0",
54 + "browserify": "14.4.0",
55 + "chai": "^3.5.0",
56 + "concurrently": "^3.1.0",
57 + "coveralls": "^3.0.2",
58 + "istanbul": "^0.4.5",
59 + "karma": "^3.0.0",
60 + "karma-chai": "^0.1.0",
61 + "karma-mocha": "^1.3.0",
62 + "karma-phantomjs-launcher": "^1.0.2",
63 + "mocha": "^5.2.0",
64 + "mocha-lcov-reporter": "^1.2.0",
65 + "rimraf": "^2.5.4",
66 + "xo": "^0.23.0"
67 + },
68 + "files": [
69 + "src",
70 + "dist/debug.js",
71 + "LICENSE",
72 + "README.md"
73 + ],
74 + "homepage": "https://github.com/visionmedia/debug#readme",
75 + "keywords": [
76 + "debug",
77 + "log",
78 + "debugger"
79 + ],
80 + "license": "MIT",
81 + "main": "./src/index.js",
82 + "name": "debug",
83 + "repository": {
84 + "type": "git",
85 + "url": "git://github.com/visionmedia/debug.git"
86 + },
87 + "scripts": {
88 + "build": "npm run build:debug && npm run build:test",
89 + "build:debug": "babel -o dist/debug.js dist/debug.es6.js > dist/debug.js",
90 + "build:test": "babel -d dist test.js",
91 + "clean": "rimraf dist coverage",
92 + "lint": "xo",
93 + "prebuild:debug": "mkdir -p dist && browserify --standalone debug -o dist/debug.es6.js .",
94 + "pretest:browser": "npm run build",
95 + "test": "npm run test:node && npm run test:browser",
96 + "test:browser": "karma start --single-run",
97 + "test:coverage": "cat ./coverage/lcov.info | coveralls",
98 + "test:node": "istanbul cover _mocha -- test.js"
99 + },
100 + "unpkg": "./dist/debug.js",
101 + "version": "4.1.1"
102 +}
1 +/* eslint-env browser */
2 +
3 +/**
4 + * This is the web browser implementation of `debug()`.
5 + */
6 +
7 +exports.log = log;
8 +exports.formatArgs = formatArgs;
9 +exports.save = save;
10 +exports.load = load;
11 +exports.useColors = useColors;
12 +exports.storage = localstorage();
13 +
14 +/**
15 + * Colors.
16 + */
17 +
18 +exports.colors = [
19 + '#0000CC',
20 + '#0000FF',
21 + '#0033CC',
22 + '#0033FF',
23 + '#0066CC',
24 + '#0066FF',
25 + '#0099CC',
26 + '#0099FF',
27 + '#00CC00',
28 + '#00CC33',
29 + '#00CC66',
30 + '#00CC99',
31 + '#00CCCC',
32 + '#00CCFF',
33 + '#3300CC',
34 + '#3300FF',
35 + '#3333CC',
36 + '#3333FF',
37 + '#3366CC',
38 + '#3366FF',
39 + '#3399CC',
40 + '#3399FF',
41 + '#33CC00',
42 + '#33CC33',
43 + '#33CC66',
44 + '#33CC99',
45 + '#33CCCC',
46 + '#33CCFF',
47 + '#6600CC',
48 + '#6600FF',
49 + '#6633CC',
50 + '#6633FF',
51 + '#66CC00',
52 + '#66CC33',
53 + '#9900CC',
54 + '#9900FF',
55 + '#9933CC',
56 + '#9933FF',
57 + '#99CC00',
58 + '#99CC33',
59 + '#CC0000',
60 + '#CC0033',
61 + '#CC0066',
62 + '#CC0099',
63 + '#CC00CC',
64 + '#CC00FF',
65 + '#CC3300',
66 + '#CC3333',
67 + '#CC3366',
68 + '#CC3399',
69 + '#CC33CC',
70 + '#CC33FF',
71 + '#CC6600',
72 + '#CC6633',
73 + '#CC9900',
74 + '#CC9933',
75 + '#CCCC00',
76 + '#CCCC33',
77 + '#FF0000',
78 + '#FF0033',
79 + '#FF0066',
80 + '#FF0099',
81 + '#FF00CC',
82 + '#FF00FF',
83 + '#FF3300',
84 + '#FF3333',
85 + '#FF3366',
86 + '#FF3399',
87 + '#FF33CC',
88 + '#FF33FF',
89 + '#FF6600',
90 + '#FF6633',
91 + '#FF9900',
92 + '#FF9933',
93 + '#FFCC00',
94 + '#FFCC33'
95 +];
96 +
97 +/**
98 + * Currently only WebKit-based Web Inspectors, Firefox >= v31,
99 + * and the Firebug extension (any Firefox version) are known
100 + * to support "%c" CSS customizations.
101 + *
102 + * TODO: add a `localStorage` variable to explicitly enable/disable colors
103 + */
104 +
105 +// eslint-disable-next-line complexity
106 +function useColors() {
107 + // NB: In an Electron preload script, document will be defined but not fully
108 + // initialized. Since we know we're in Chrome, we'll just detect this case
109 + // explicitly
110 + if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
111 + return true;
112 + }
113 +
114 + // Internet Explorer and Edge do not support colors.
115 + if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
116 + return false;
117 + }
118 +
119 + // Is webkit? http://stackoverflow.com/a/16459606/376773
120 + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
121 + return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
122 + // Is firebug? http://stackoverflow.com/a/398120/376773
123 + (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
124 + // Is firefox >= v31?
125 + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
126 + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
127 + // Double check webkit in userAgent just in case we are in a worker
128 + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
129 +}
130 +
131 +/**
132 + * Colorize log arguments if enabled.
133 + *
134 + * @api public
135 + */
136 +
137 +function formatArgs(args) {
138 + args[0] = (this.useColors ? '%c' : '') +
139 + this.namespace +
140 + (this.useColors ? ' %c' : ' ') +
141 + args[0] +
142 + (this.useColors ? '%c ' : ' ') +
143 + '+' + module.exports.humanize(this.diff);
144 +
145 + if (!this.useColors) {
146 + return;
147 + }
148 +
149 + const c = 'color: ' + this.color;
150 + args.splice(1, 0, c, 'color: inherit');
151 +
152 + // The final "%c" is somewhat tricky, because there could be other
153 + // arguments passed either before or after the %c, so we need to
154 + // figure out the correct index to insert the CSS into
155 + let index = 0;
156 + let lastC = 0;
157 + args[0].replace(/%[a-zA-Z%]/g, match => {
158 + if (match === '%%') {
159 + return;
160 + }
161 + index++;
162 + if (match === '%c') {
163 + // We only are interested in the *last* %c
164 + // (the user may have provided their own)
165 + lastC = index;
166 + }
167 + });
168 +
169 + args.splice(lastC, 0, c);
170 +}
171 +
172 +/**
173 + * Invokes `console.log()` when available.
174 + * No-op when `console.log` is not a "function".
175 + *
176 + * @api public
177 + */
178 +function log(...args) {
179 + // This hackery is required for IE8/9, where
180 + // the `console.log` function doesn't have 'apply'
181 + return typeof console === 'object' &&
182 + console.log &&
183 + console.log(...args);
184 +}
185 +
186 +/**
187 + * Save `namespaces`.
188 + *
189 + * @param {String} namespaces
190 + * @api private
191 + */
192 +function save(namespaces) {
193 + try {
194 + if (namespaces) {
195 + exports.storage.setItem('debug', namespaces);
196 + } else {
197 + exports.storage.removeItem('debug');
198 + }
199 + } catch (error) {
200 + // Swallow
201 + // XXX (@Qix-) should we be logging these?
202 + }
203 +}
204 +
205 +/**
206 + * Load `namespaces`.
207 + *
208 + * @return {String} returns the previously persisted debug modes
209 + * @api private
210 + */
211 +function load() {
212 + let r;
213 + try {
214 + r = exports.storage.getItem('debug');
215 + } catch (error) {
216 + // Swallow
217 + // XXX (@Qix-) should we be logging these?
218 + }
219 +
220 + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
221 + if (!r && typeof process !== 'undefined' && 'env' in process) {
222 + r = process.env.DEBUG;
223 + }
224 +
225 + return r;
226 +}
227 +
228 +/**
229 + * Localstorage attempts to return the localstorage.
230 + *
231 + * This is necessary because safari throws
232 + * when a user disables cookies/localstorage
233 + * and you attempt to access it.
234 + *
235 + * @return {LocalStorage}
236 + * @api private
237 + */
238 +
239 +function localstorage() {
240 + try {
241 + // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
242 + // The Browser also has localStorage in the global context.
243 + return localStorage;
244 + } catch (error) {
245 + // Swallow
246 + // XXX (@Qix-) should we be logging these?
247 + }
248 +}
249 +
250 +module.exports = require('./common')(exports);
251 +
252 +const {formatters} = module.exports;
253 +
254 +/**
255 + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
256 + */
257 +
258 +formatters.j = function (v) {
259 + try {
260 + return JSON.stringify(v);
261 + } catch (error) {
262 + return '[UnexpectedJSONParseError]: ' + error.message;
263 + }
264 +};
1 +
2 +/**
3 + * This is the common logic for both the Node.js and web browser
4 + * implementations of `debug()`.
5 + */
6 +
7 +function setup(env) {
8 + createDebug.debug = createDebug;
9 + createDebug.default = createDebug;
10 + createDebug.coerce = coerce;
11 + createDebug.disable = disable;
12 + createDebug.enable = enable;
13 + createDebug.enabled = enabled;
14 + createDebug.humanize = require('ms');
15 +
16 + Object.keys(env).forEach(key => {
17 + createDebug[key] = env[key];
18 + });
19 +
20 + /**
21 + * Active `debug` instances.
22 + */
23 + createDebug.instances = [];
24 +
25 + /**
26 + * The currently active debug mode names, and names to skip.
27 + */
28 +
29 + createDebug.names = [];
30 + createDebug.skips = [];
31 +
32 + /**
33 + * Map of special "%n" handling functions, for the debug "format" argument.
34 + *
35 + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
36 + */
37 + createDebug.formatters = {};
38 +
39 + /**
40 + * Selects a color for a debug namespace
41 + * @param {String} namespace The namespace string for the for the debug instance to be colored
42 + * @return {Number|String} An ANSI color code for the given namespace
43 + * @api private
44 + */
45 + function selectColor(namespace) {
46 + let hash = 0;
47 +
48 + for (let i = 0; i < namespace.length; i++) {
49 + hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
50 + hash |= 0; // Convert to 32bit integer
51 + }
52 +
53 + return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
54 + }
55 + createDebug.selectColor = selectColor;
56 +
57 + /**
58 + * Create a debugger with the given `namespace`.
59 + *
60 + * @param {String} namespace
61 + * @return {Function}
62 + * @api public
63 + */
64 + function createDebug(namespace) {
65 + let prevTime;
66 +
67 + function debug(...args) {
68 + // Disabled?
69 + if (!debug.enabled) {
70 + return;
71 + }
72 +
73 + const self = debug;
74 +
75 + // Set `diff` timestamp
76 + const curr = Number(new Date());
77 + const ms = curr - (prevTime || curr);
78 + self.diff = ms;
79 + self.prev = prevTime;
80 + self.curr = curr;
81 + prevTime = curr;
82 +
83 + args[0] = createDebug.coerce(args[0]);
84 +
85 + if (typeof args[0] !== 'string') {
86 + // Anything else let's inspect with %O
87 + args.unshift('%O');
88 + }
89 +
90 + // Apply any `formatters` transformations
91 + let index = 0;
92 + args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
93 + // If we encounter an escaped % then don't increase the array index
94 + if (match === '%%') {
95 + return match;
96 + }
97 + index++;
98 + const formatter = createDebug.formatters[format];
99 + if (typeof formatter === 'function') {
100 + const val = args[index];
101 + match = formatter.call(self, val);
102 +
103 + // Now we need to remove `args[index]` since it's inlined in the `format`
104 + args.splice(index, 1);
105 + index--;
106 + }
107 + return match;
108 + });
109 +
110 + // Apply env-specific formatting (colors, etc.)
111 + createDebug.formatArgs.call(self, args);
112 +
113 + const logFn = self.log || createDebug.log;
114 + logFn.apply(self, args);
115 + }
116 +
117 + debug.namespace = namespace;
118 + debug.enabled = createDebug.enabled(namespace);
119 + debug.useColors = createDebug.useColors();
120 + debug.color = selectColor(namespace);
121 + debug.destroy = destroy;
122 + debug.extend = extend;
123 + // Debug.formatArgs = formatArgs;
124 + // debug.rawLog = rawLog;
125 +
126 + // env-specific initialization logic for debug instances
127 + if (typeof createDebug.init === 'function') {
128 + createDebug.init(debug);
129 + }
130 +
131 + createDebug.instances.push(debug);
132 +
133 + return debug;
134 + }
135 +
136 + function destroy() {
137 + const index = createDebug.instances.indexOf(this);
138 + if (index !== -1) {
139 + createDebug.instances.splice(index, 1);
140 + return true;
141 + }
142 + return false;
143 + }
144 +
145 + function extend(namespace, delimiter) {
146 + const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
147 + newDebug.log = this.log;
148 + return newDebug;
149 + }
150 +
151 + /**
152 + * Enables a debug mode by namespaces. This can include modes
153 + * separated by a colon and wildcards.
154 + *
155 + * @param {String} namespaces
156 + * @api public
157 + */
158 + function enable(namespaces) {
159 + createDebug.save(namespaces);
160 +
161 + createDebug.names = [];
162 + createDebug.skips = [];
163 +
164 + let i;
165 + const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
166 + const len = split.length;
167 +
168 + for (i = 0; i < len; i++) {
169 + if (!split[i]) {
170 + // ignore empty strings
171 + continue;
172 + }
173 +
174 + namespaces = split[i].replace(/\*/g, '.*?');
175 +
176 + if (namespaces[0] === '-') {
177 + createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
178 + } else {
179 + createDebug.names.push(new RegExp('^' + namespaces + '$'));
180 + }
181 + }
182 +
183 + for (i = 0; i < createDebug.instances.length; i++) {
184 + const instance = createDebug.instances[i];
185 + instance.enabled = createDebug.enabled(instance.namespace);
186 + }
187 + }
188 +
189 + /**
190 + * Disable debug output.
191 + *
192 + * @return {String} namespaces
193 + * @api public
194 + */
195 + function disable() {
196 + const namespaces = [
197 + ...createDebug.names.map(toNamespace),
198 + ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
199 + ].join(',');
200 + createDebug.enable('');
201 + return namespaces;
202 + }
203 +
204 + /**
205 + * Returns true if the given mode name is enabled, false otherwise.
206 + *
207 + * @param {String} name
208 + * @return {Boolean}
209 + * @api public
210 + */
211 + function enabled(name) {
212 + if (name[name.length - 1] === '*') {
213 + return true;
214 + }
215 +
216 + let i;
217 + let len;
218 +
219 + for (i = 0, len = createDebug.skips.length; i < len; i++) {
220 + if (createDebug.skips[i].test(name)) {
221 + return false;
222 + }
223 + }
224 +
225 + for (i = 0, len = createDebug.names.length; i < len; i++) {
226 + if (createDebug.names[i].test(name)) {
227 + return true;
228 + }
229 + }
230 +
231 + return false;
232 + }
233 +
234 + /**
235 + * Convert regexp to namespace
236 + *
237 + * @param {RegExp} regxep
238 + * @return {String} namespace
239 + * @api private
240 + */
241 + function toNamespace(regexp) {
242 + return regexp.toString()
243 + .substring(2, regexp.toString().length - 2)
244 + .replace(/\.\*\?$/, '*');
245 + }
246 +
247 + /**
248 + * Coerce `val`.
249 + *
250 + * @param {Mixed} val
251 + * @return {Mixed}
252 + * @api private
253 + */
254 + function coerce(val) {
255 + if (val instanceof Error) {
256 + return val.stack || val.message;
257 + }
258 + return val;
259 + }
260 +
261 + createDebug.enable(createDebug.load());
262 +
263 + return createDebug;
264 +}
265 +
266 +module.exports = setup;
1 +/**
2 + * Detect Electron renderer / nwjs process, which is node, but we should
3 + * treat as a browser.
4 + */
5 +
6 +if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
7 + module.exports = require('./browser.js');
8 +} else {
9 + module.exports = require('./node.js');
10 +}
1 +/**
2 + * Module dependencies.
3 + */
4 +
5 +const tty = require('tty');
6 +const util = require('util');
7 +
8 +/**
9 + * This is the Node.js implementation of `debug()`.
10 + */
11 +
12 +exports.init = init;
13 +exports.log = log;
14 +exports.formatArgs = formatArgs;
15 +exports.save = save;
16 +exports.load = load;
17 +exports.useColors = useColors;
18 +
19 +/**
20 + * Colors.
21 + */
22 +
23 +exports.colors = [6, 2, 3, 4, 5, 1];
24 +
25 +try {
26 + // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
27 + // eslint-disable-next-line import/no-extraneous-dependencies
28 + const supportsColor = require('supports-color');
29 +
30 + if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
31 + exports.colors = [
32 + 20,
33 + 21,
34 + 26,
35 + 27,
36 + 32,
37 + 33,
38 + 38,
39 + 39,
40 + 40,
41 + 41,
42 + 42,
43 + 43,
44 + 44,
45 + 45,
46 + 56,
47 + 57,
48 + 62,
49 + 63,
50 + 68,
51 + 69,
52 + 74,
53 + 75,
54 + 76,
55 + 77,
56 + 78,
57 + 79,
58 + 80,
59 + 81,
60 + 92,
61 + 93,
62 + 98,
63 + 99,
64 + 112,
65 + 113,
66 + 128,
67 + 129,
68 + 134,
69 + 135,
70 + 148,
71 + 149,
72 + 160,
73 + 161,
74 + 162,
75 + 163,
76 + 164,
77 + 165,
78 + 166,
79 + 167,
80 + 168,
81 + 169,
82 + 170,
83 + 171,
84 + 172,
85 + 173,
86 + 178,
87 + 179,
88 + 184,
89 + 185,
90 + 196,
91 + 197,
92 + 198,
93 + 199,
94 + 200,
95 + 201,
96 + 202,
97 + 203,
98 + 204,
99 + 205,
100 + 206,
101 + 207,
102 + 208,
103 + 209,
104 + 214,
105 + 215,
106 + 220,
107 + 221
108 + ];
109 + }
110 +} catch (error) {
111 + // Swallow - we only care if `supports-color` is available; it doesn't have to be.
112 +}
113 +
114 +/**
115 + * Build up the default `inspectOpts` object from the environment variables.
116 + *
117 + * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
118 + */
119 +
120 +exports.inspectOpts = Object.keys(process.env).filter(key => {
121 + return /^debug_/i.test(key);
122 +}).reduce((obj, key) => {
123 + // Camel-case
124 + const prop = key
125 + .substring(6)
126 + .toLowerCase()
127 + .replace(/_([a-z])/g, (_, k) => {
128 + return k.toUpperCase();
129 + });
130 +
131 + // Coerce string value into JS value
132 + let val = process.env[key];
133 + if (/^(yes|on|true|enabled)$/i.test(val)) {
134 + val = true;
135 + } else if (/^(no|off|false|disabled)$/i.test(val)) {
136 + val = false;
137 + } else if (val === 'null') {
138 + val = null;
139 + } else {
140 + val = Number(val);
141 + }
142 +
143 + obj[prop] = val;
144 + return obj;
145 +}, {});
146 +
147 +/**
148 + * Is stdout a TTY? Colored output is enabled when `true`.
149 + */
150 +
151 +function useColors() {
152 + return 'colors' in exports.inspectOpts ?
153 + Boolean(exports.inspectOpts.colors) :
154 + tty.isatty(process.stderr.fd);
155 +}
156 +
157 +/**
158 + * Adds ANSI color escape codes if enabled.
159 + *
160 + * @api public
161 + */
162 +
163 +function formatArgs(args) {
164 + const {namespace: name, useColors} = this;
165 +
166 + if (useColors) {
167 + const c = this.color;
168 + const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
169 + const prefix = ` ${colorCode};1m${name} \u001B[0m`;
170 +
171 + args[0] = prefix + args[0].split('\n').join('\n' + prefix);
172 + args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
173 + } else {
174 + args[0] = getDate() + name + ' ' + args[0];
175 + }
176 +}
177 +
178 +function getDate() {
179 + if (exports.inspectOpts.hideDate) {
180 + return '';
181 + }
182 + return new Date().toISOString() + ' ';
183 +}
184 +
185 +/**
186 + * Invokes `util.format()` with the specified arguments and writes to stderr.
187 + */
188 +
189 +function log(...args) {
190 + return process.stderr.write(util.format(...args) + '\n');
191 +}
192 +
193 +/**
194 + * Save `namespaces`.
195 + *
196 + * @param {String} namespaces
197 + * @api private
198 + */
199 +function save(namespaces) {
200 + if (namespaces) {
201 + process.env.DEBUG = namespaces;
202 + } else {
203 + // If you set a process.env field to null or undefined, it gets cast to the
204 + // string 'null' or 'undefined'. Just delete instead.
205 + delete process.env.DEBUG;
206 + }
207 +}
208 +
209 +/**
210 + * Load `namespaces`.
211 + *
212 + * @return {String} returns the previously persisted debug modes
213 + * @api private
214 + */
215 +
216 +function load() {
217 + return process.env.DEBUG;
218 +}
219 +
220 +/**
221 + * Init logic for `debug` instances.
222 + *
223 + * Create a new `inspectOpts` object in case `useColors` is set
224 + * differently for a particular `debug` instance.
225 + */
226 +
227 +function init(debug) {
228 + debug.inspectOpts = {};
229 +
230 + const keys = Object.keys(exports.inspectOpts);
231 + for (let i = 0; i < keys.length; i++) {
232 + debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
233 + }
234 +}
235 +
236 +module.exports = require('./common')(exports);
237 +
238 +const {formatters} = module.exports;
239 +
240 +/**
241 + * Map %o to `util.inspect()`, all on a single line.
242 + */
243 +
244 +formatters.o = function (v) {
245 + this.inspectOpts.colors = this.useColors;
246 + return util.inspect(v, this.inspectOpts)
247 + .replace(/\s*\n\s*/g, ' ');
248 +};
249 +
250 +/**
251 + * Map %O to `util.inspect()`, allowing multiple lines if needed.
252 + */
253 +
254 +formatters.O = function (v) {
255 + this.inspectOpts.colors = this.useColors;
256 + return util.inspect(v, this.inspectOpts);
257 +};
1 +/**
2 + * Helpers.
3 + */
4 +
5 +var s = 1000;
6 +var m = s * 60;
7 +var h = m * 60;
8 +var d = h * 24;
9 +var w = d * 7;
10 +var y = d * 365.25;
11 +
12 +/**
13 + * Parse or format the given `val`.
14 + *
15 + * Options:
16 + *
17 + * - `long` verbose formatting [false]
18 + *
19 + * @param {String|Number} val
20 + * @param {Object} [options]
21 + * @throws {Error} throw an error if val is not a non-empty string or a number
22 + * @return {String|Number}
23 + * @api public
24 + */
25 +
26 +module.exports = function(val, options) {
27 + options = options || {};
28 + var type = typeof val;
29 + if (type === 'string' && val.length > 0) {
30 + return parse(val);
31 + } else if (type === 'number' && isFinite(val)) {
32 + return options.long ? fmtLong(val) : fmtShort(val);
33 + }
34 + throw new Error(
35 + 'val is not a non-empty string or a valid number. val=' +
36 + JSON.stringify(val)
37 + );
38 +};
39 +
40 +/**
41 + * Parse the given `str` and return milliseconds.
42 + *
43 + * @param {String} str
44 + * @return {Number}
45 + * @api private
46 + */
47 +
48 +function parse(str) {
49 + str = String(str);
50 + if (str.length > 100) {
51 + return;
52 + }
53 + var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
54 + str
55 + );
56 + if (!match) {
57 + return;
58 + }
59 + var n = parseFloat(match[1]);
60 + var type = (match[2] || 'ms').toLowerCase();
61 + switch (type) {
62 + case 'years':
63 + case 'year':
64 + case 'yrs':
65 + case 'yr':
66 + case 'y':
67 + return n * y;
68 + case 'weeks':
69 + case 'week':
70 + case 'w':
71 + return n * w;
72 + case 'days':
73 + case 'day':
74 + case 'd':
75 + return n * d;
76 + case 'hours':
77 + case 'hour':
78 + case 'hrs':
79 + case 'hr':
80 + case 'h':
81 + return n * h;
82 + case 'minutes':
83 + case 'minute':
84 + case 'mins':
85 + case 'min':
86 + case 'm':
87 + return n * m;
88 + case 'seconds':
89 + case 'second':
90 + case 'secs':
91 + case 'sec':
92 + case 's':
93 + return n * s;
94 + case 'milliseconds':
95 + case 'millisecond':
96 + case 'msecs':
97 + case 'msec':
98 + case 'ms':
99 + return n;
100 + default:
101 + return undefined;
102 + }
103 +}
104 +
105 +/**
106 + * Short format for `ms`.
107 + *
108 + * @param {Number} ms
109 + * @return {String}
110 + * @api private
111 + */
112 +
113 +function fmtShort(ms) {
114 + var msAbs = Math.abs(ms);
115 + if (msAbs >= d) {
116 + return Math.round(ms / d) + 'd';
117 + }
118 + if (msAbs >= h) {
119 + return Math.round(ms / h) + 'h';
120 + }
121 + if (msAbs >= m) {
122 + return Math.round(ms / m) + 'm';
123 + }
124 + if (msAbs >= s) {
125 + return Math.round(ms / s) + 's';
126 + }
127 + return ms + 'ms';
128 +}
129 +
130 +/**
131 + * Long format for `ms`.
132 + *
133 + * @param {Number} ms
134 + * @return {String}
135 + * @api private
136 + */
137 +
138 +function fmtLong(ms) {
139 + var msAbs = Math.abs(ms);
140 + if (msAbs >= d) {
141 + return plural(ms, msAbs, d, 'day');
142 + }
143 + if (msAbs >= h) {
144 + return plural(ms, msAbs, h, 'hour');
145 + }
146 + if (msAbs >= m) {
147 + return plural(ms, msAbs, m, 'minute');
148 + }
149 + if (msAbs >= s) {
150 + return plural(ms, msAbs, s, 'second');
151 + }
152 + return ms + ' ms';
153 +}
154 +
155 +/**
156 + * Pluralization helper.
157 + */
158 +
159 +function plural(ms, msAbs, n, name) {
160 + var isPlural = msAbs >= n * 1.5;
161 + return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
162 +}
1 +The MIT License (MIT)
2 +
3 +Copyright (c) 2016 Zeit, Inc.
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in all
13 +copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 +SOFTWARE.
1 +{
2 + "_from": "ms@^2.1.1",
3 + "_id": "ms@2.1.2",
4 + "_inBundle": false,
5 + "_integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
6 + "_location": "/messaging-api-line/ms",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "ms@^2.1.1",
12 + "name": "ms",
13 + "escapedName": "ms",
14 + "rawSpec": "^2.1.1",
15 + "saveSpec": null,
16 + "fetchSpec": "^2.1.1"
17 + },
18 + "_requiredBy": [
19 + "/messaging-api-line/debug"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
22 + "_shasum": "d09d1f357b443f493382a8eb3ccd183872ae6009",
23 + "_spec": "ms@^2.1.1",
24 + "_where": "C:\\Users\\김수민\\Desktop\\ostt\\LINEBOT\\node_modules\\messaging-api-line\\node_modules\\debug",
25 + "bugs": {
26 + "url": "https://github.com/zeit/ms/issues"
27 + },
28 + "bundleDependencies": false,
29 + "deprecated": false,
30 + "description": "Tiny millisecond conversion utility",
31 + "devDependencies": {
32 + "eslint": "4.12.1",
33 + "expect.js": "0.3.1",
34 + "husky": "0.14.3",
35 + "lint-staged": "5.0.0",
36 + "mocha": "4.0.1"
37 + },
38 + "eslintConfig": {
39 + "extends": "eslint:recommended",
40 + "env": {
41 + "node": true,
42 + "es6": true
43 + }
44 + },
45 + "files": [
46 + "index.js"
47 + ],
48 + "homepage": "https://github.com/zeit/ms#readme",
49 + "license": "MIT",
50 + "lint-staged": {
51 + "*.js": [
52 + "npm run lint",
53 + "prettier --single-quote --write",
54 + "git add"
55 + ]
56 + },
57 + "main": "./index",
58 + "name": "ms",
59 + "repository": {
60 + "type": "git",
61 + "url": "git+https://github.com/zeit/ms.git"
62 + },
63 + "scripts": {
64 + "lint": "eslint lib/* bin/*",
65 + "precommit": "lint-staged",
66 + "test": "mocha tests.js"
67 + },
68 + "version": "2.1.2"
69 +}
1 +# ms
2 +
3 +[![Build Status](https://travis-ci.org/zeit/ms.svg?branch=master)](https://travis-ci.org/zeit/ms)
4 +[![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/zeit)
5 +
6 +Use this package to easily convert various time formats to milliseconds.
7 +
8 +## Examples
9 +
10 +```js
11 +ms('2 days') // 172800000
12 +ms('1d') // 86400000
13 +ms('10h') // 36000000
14 +ms('2.5 hrs') // 9000000
15 +ms('2h') // 7200000
16 +ms('1m') // 60000
17 +ms('5s') // 5000
18 +ms('1y') // 31557600000
19 +ms('100') // 100
20 +ms('-3 days') // -259200000
21 +ms('-1h') // -3600000
22 +ms('-200') // -200
23 +```
24 +
25 +### Convert from Milliseconds
26 +
27 +```js
28 +ms(60000) // "1m"
29 +ms(2 * 60000) // "2m"
30 +ms(-3 * 60000) // "-3m"
31 +ms(ms('10 hours')) // "10h"
32 +```
33 +
34 +### Time Format Written-Out
35 +
36 +```js
37 +ms(60000, { long: true }) // "1 minute"
38 +ms(2 * 60000, { long: true }) // "2 minutes"
39 +ms(-3 * 60000, { long: true }) // "-3 minutes"
40 +ms(ms('10 hours'), { long: true }) // "10 hours"
41 +```
42 +
43 +## Features
44 +
45 +- Works both in [Node.js](https://nodejs.org) and in the browser
46 +- If a number is supplied to `ms`, a string with a unit is returned
47 +- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`)
48 +- If you pass a string with a number and a valid unit, the number of equivalent milliseconds is returned
49 +
50 +## Related Packages
51 +
52 +- [ms.macro](https://github.com/knpwrs/ms.macro) - Run `ms` as a macro at build-time.
53 +
54 +## Caught a Bug?
55 +
56 +1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
57 +2. Link the package to the global module directory: `npm link`
58 +3. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, Node.js will now use your clone of ms!
59 +
60 +As always, you can run the tests using: `npm test`
1 +{
2 + "_from": "messaging-api-line",
3 + "_id": "messaging-api-line@0.8.3",
4 + "_inBundle": false,
5 + "_integrity": "sha512-EQRqW9UMtfQPw/PfnkFue7eSXZlxX2Ke5frFGhl6UHUW5Qfi4KPpvAqf2VTaU/cU7rGhGnZWuNbjoxkCWDyT8A==",
6 + "_location": "/messaging-api-line",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "tag",
10 + "registry": true,
11 + "raw": "messaging-api-line",
12 + "name": "messaging-api-line",
13 + "escapedName": "messaging-api-line",
14 + "rawSpec": "",
15 + "saveSpec": null,
16 + "fetchSpec": "latest"
17 + },
18 + "_requiredBy": [
19 + "#USER",
20 + "/"
21 + ],
22 + "_resolved": "https://registry.npmjs.org/messaging-api-line/-/messaging-api-line-0.8.3.tgz",
23 + "_shasum": "53344ba1e88bc91da5c03df5618e32a395e176e8",
24 + "_spec": "messaging-api-line",
25 + "_where": "C:\\Users\\김수민\\Desktop\\ostt\\LINEBOT",
26 + "browser": "lib/browser.js",
27 + "bugs": {
28 + "url": "https://github.com/Yoctol/messaging-apis/issues"
29 + },
30 + "bundleDependencies": false,
31 + "dependencies": {
32 + "axios": "^0.19.0",
33 + "axios-error": "^0.8.1",
34 + "debug": "^4.1.1",
35 + "image-type": "^4.1.0",
36 + "invariant": "^2.2.4",
37 + "lodash.omit": "^4.5.0",
38 + "url-join": "^4.0.1"
39 + },
40 + "deprecated": false,
41 + "description": "Messaging API client for LINE",
42 + "devDependencies": {
43 + "axios-mock-adapter": "^1.17.0"
44 + },
45 + "engines": {
46 + "node": ">=8"
47 + },
48 + "gitHead": "874202b421e7b302d84d9b039fbfc30b39a77ee3",
49 + "homepage": "https://github.com/Yoctol/messaging-apis#readme",
50 + "keywords": [
51 + "bot",
52 + "chatbot",
53 + "line",
54 + "messaging-apis"
55 + ],
56 + "license": "MIT",
57 + "main": "lib/index.js",
58 + "name": "messaging-api-line",
59 + "repository": {
60 + "type": "git",
61 + "url": "git+https://github.com/Yoctol/messaging-apis.git"
62 + },
63 + "version": "0.8.3"
64 +}
1 +/* @flow */
2 +import invariant from 'invariant';
3 +import omit from 'lodash.omit';
4 +
5 +import {
6 + type AudioMessage,
7 + type ButtonsTemplate,
8 + type CarouselTemplate,
9 + type ColumnObject,
10 + type ConfirmTemplate,
11 + type FlexContainer,
12 + type FlexMessage,
13 + type ImageCarouselColumnObject,
14 + type ImageCarouselTemplate,
15 + type ImageMapAction,
16 + type ImageMapMessage,
17 + type ImageMapVideo,
18 + type ImageMessage,
19 + type Location,
20 + type LocationMessage,
21 + type MessageOptions,
22 + type QuickReply,
23 + type StickerMessage,
24 + type Template,
25 + type TemplateAction,
26 + type TemplateMessage,
27 + type TextMessage,
28 + type VideoMessage,
29 +} from './LineTypes';
30 +
31 +function createText(text: string, options: MessageOptions = {}): TextMessage {
32 + return {
33 + type: 'text',
34 + text,
35 + ...omit(options, 'accessToken'),
36 + };
37 +}
38 +
39 +function createImage(
40 + contentUrlOrImage: string | Object,
41 + previewUrlOrOptions?: string | MessageOptions
42 +): ImageMessage {
43 + if (previewUrlOrOptions) {
44 + if (
45 + typeof contentUrlOrImage === 'object' &&
46 + typeof previewUrlOrOptions === 'object'
47 + ) {
48 + const image = contentUrlOrImage;
49 + const options = previewUrlOrOptions;
50 + return {
51 + type: 'image',
52 + originalContentUrl: image.originalContentUrl,
53 + previewImageUrl: image.previewImageUrl || image.originalContentUrl,
54 + ...omit(options, 'accessToken'),
55 + };
56 + }
57 +
58 + if (
59 + typeof contentUrlOrImage === 'string' &&
60 + typeof previewUrlOrOptions === 'string'
61 + ) {
62 + return {
63 + type: 'image',
64 + originalContentUrl: contentUrlOrImage,
65 + previewImageUrl: previewUrlOrOptions,
66 + };
67 + }
68 + } else {
69 + if (typeof contentUrlOrImage === 'object') {
70 + const image = contentUrlOrImage;
71 + return {
72 + type: 'image',
73 + originalContentUrl: image.originalContentUrl,
74 + previewImageUrl: image.previewImageUrl || image.originalContentUrl,
75 + };
76 + }
77 +
78 + if (typeof contentUrlOrImage === 'string') {
79 + return {
80 + type: 'image',
81 + originalContentUrl: contentUrlOrImage,
82 + previewImageUrl: contentUrlOrImage,
83 + };
84 + }
85 + }
86 +
87 + invariant(false, 'Line#createImage: Wrong type of arguments.');
88 +}
89 +
90 +function createVideo(
91 + contentUrlOrVideo: string | Object,
92 + previewImageUrlOrOptions?: string | MessageOptions
93 +): VideoMessage {
94 + if (
95 + typeof contentUrlOrVideo === 'string' &&
96 + typeof previewImageUrlOrOptions === 'string'
97 + ) {
98 + return {
99 + type: 'video',
100 + originalContentUrl: contentUrlOrVideo,
101 + previewImageUrl: previewImageUrlOrOptions,
102 + };
103 + }
104 +
105 + if (
106 + typeof contentUrlOrVideo === 'object' &&
107 + (!previewImageUrlOrOptions || typeof previewImageUrlOrOptions === 'object')
108 + ) {
109 + const video = contentUrlOrVideo;
110 + const options = previewImageUrlOrOptions || {};
111 + return {
112 + type: 'video',
113 + originalContentUrl: video.originalContentUrl,
114 + previewImageUrl: video.previewImageUrl,
115 + ...omit(options, 'accessToken'),
116 + };
117 + }
118 +
119 + invariant(false, 'Line#createVideo: Wrong type of arguments.');
120 +}
121 +
122 +function createAudio(
123 + contentUrlOrAudio: string | Object,
124 + durationOrOptions: number | MessageOptions
125 +): AudioMessage {
126 + if (
127 + typeof contentUrlOrAudio === 'string' &&
128 + typeof durationOrOptions === 'number'
129 + ) {
130 + return {
131 + type: 'audio',
132 + originalContentUrl: contentUrlOrAudio,
133 + duration: durationOrOptions,
134 + };
135 + }
136 +
137 + if (
138 + typeof contentUrlOrAudio === 'object' &&
139 + (!durationOrOptions || typeof durationOrOptions === 'object')
140 + ) {
141 + const audio = contentUrlOrAudio;
142 + const options = durationOrOptions || {};
143 + return {
144 + type: 'audio',
145 + originalContentUrl: audio.originalContentUrl,
146 + duration: audio.duration,
147 + ...omit(options, 'accessToken'),
148 + };
149 + }
150 +
151 + invariant(false, 'Line#createAudio: Wrong type of arguments.');
152 +}
153 +
154 +function createLocation(
155 + { title, address, latitude, longitude }: Location,
156 + options?: MessageOptions = {}
157 +): LocationMessage {
158 + return {
159 + type: 'location',
160 + title,
161 + address,
162 + latitude,
163 + longitude,
164 + ...omit(options, 'accessToken'),
165 + };
166 +}
167 +
168 +function createSticker(
169 + packageIdOrSticker: string | Object,
170 + stickerIdOrOptions: string | MessageOptions
171 +): StickerMessage {
172 + if (
173 + typeof packageIdOrSticker === 'string' &&
174 + typeof stickerIdOrOptions === 'string'
175 + ) {
176 + return {
177 + type: 'sticker',
178 + packageId: packageIdOrSticker,
179 + stickerId: stickerIdOrOptions,
180 + };
181 + }
182 +
183 + if (
184 + typeof packageIdOrSticker === 'object' &&
185 + (!stickerIdOrOptions || typeof stickerIdOrOptions === 'object')
186 + ) {
187 + const sticker = packageIdOrSticker;
188 + const options = stickerIdOrOptions || {};
189 + return {
190 + type: 'sticker',
191 + packageId: sticker.packageId,
192 + stickerId: sticker.stickerId,
193 + ...omit(options, 'accessToken'),
194 + };
195 + }
196 +
197 + invariant(false, 'Line#createSticker: Wrong type of arguments.');
198 +}
199 +
200 +function createImagemap(
201 + altText: string,
202 + {
203 + baseUrl,
204 + baseSize,
205 + baseHeight,
206 + baseWidth,
207 + video,
208 + actions,
209 + }: {
210 + baseUrl: string,
211 + baseSize: {
212 + height: number,
213 + width: number,
214 + },
215 + baseHeight: number,
216 + baseWidth: number,
217 + video?: ImageMapVideo,
218 + actions: Array<ImageMapAction>,
219 + },
220 + options?: MessageOptions = {}
221 +): ImageMapMessage {
222 + return {
223 + type: 'imagemap',
224 + baseUrl,
225 + altText,
226 + baseSize: baseSize || {
227 + height: baseHeight,
228 + width: baseWidth,
229 + },
230 + video,
231 + actions,
232 + ...omit(options, 'accessToken'),
233 + };
234 +}
235 +
236 +function createTemplate(
237 + altText: string,
238 + template: Template,
239 + options?: MessageOptions = {}
240 +): TemplateMessage<any> {
241 + return {
242 + type: 'template',
243 + altText,
244 + template,
245 + ...omit(options, 'accessToken'),
246 + };
247 +}
248 +
249 +function createButtonTemplate(
250 + altText: string,
251 + {
252 + thumbnailImageUrl,
253 + imageAspectRatio,
254 + imageSize,
255 + imageBackgroundColor,
256 + title,
257 + text,
258 + defaultAction,
259 + actions,
260 + }: {
261 + thumbnailImageUrl?: string,
262 + imageAspectRatio?: 'rectangle' | 'square',
263 + imageSize?: 'cover' | 'contain',
264 + imageBackgroundColor?: string,
265 + title?: string,
266 + text: string,
267 + defaultAction?: TemplateAction,
268 + actions: Array<TemplateAction>,
269 + },
270 + options: MessageOptions = {}
271 +): TemplateMessage<ButtonsTemplate> {
272 + return createTemplate(
273 + altText,
274 + {
275 + type: 'buttons',
276 + thumbnailImageUrl,
277 + imageAspectRatio,
278 + imageSize,
279 + imageBackgroundColor,
280 + title,
281 + text,
282 + defaultAction,
283 + actions,
284 + },
285 + omit(options, 'accessToken')
286 + );
287 +}
288 +
289 +function createConfirmTemplate(
290 + altText: string,
291 + {
292 + text,
293 + actions,
294 + }: {
295 + text: string,
296 + actions: Array<TemplateAction>,
297 + },
298 + options?: MessageOptions = {}
299 +): TemplateMessage<ConfirmTemplate> {
300 + return createTemplate(
301 + altText,
302 + {
303 + type: 'confirm',
304 + text,
305 + actions,
306 + },
307 + omit(options, 'accessToken')
308 + );
309 +}
310 +
311 +function createCarouselTemplate(
312 + altText: string,
313 + columns: Array<ColumnObject>,
314 + {
315 + imageAspectRatio,
316 + imageSize,
317 + quickReply,
318 + }: {
319 + imageAspectRatio?: 'rectangle' | 'square',
320 + imageSize?: 'cover' | 'contain',
321 + quickReply?: QuickReply,
322 + } = {}
323 +): TemplateMessage<CarouselTemplate> {
324 + return createTemplate(
325 + altText,
326 + {
327 + type: 'carousel',
328 + columns,
329 + imageAspectRatio,
330 + imageSize,
331 + },
332 + { quickReply }
333 + );
334 +}
335 +
336 +function createImageCarouselTemplate(
337 + altText: string,
338 + columns: Array<ImageCarouselColumnObject>,
339 + options?: MessageOptions = {}
340 +): TemplateMessage<ImageCarouselTemplate> {
341 + return createTemplate(
342 + altText,
343 + {
344 + type: 'image_carousel',
345 + columns,
346 + },
347 + omit(options, 'accessToken')
348 + );
349 +}
350 +
351 +function createFlex(
352 + altText: string,
353 + contents: FlexContainer,
354 + options?: MessageOptions = {}
355 +): FlexMessage {
356 + return {
357 + type: 'flex',
358 + altText,
359 + contents,
360 + ...omit(options, 'accessToken'),
361 + };
362 +}
363 +
364 +const Line = {
365 + createText,
366 + createImage,
367 + createVideo,
368 + createAudio,
369 + createLocation,
370 + createSticker,
371 + createImagemap,
372 + createTemplate,
373 + createButtonsTemplate: createButtonTemplate,
374 + createButtonTemplate,
375 + createConfirmTemplate,
376 + createCarouselTemplate,
377 + createImageCarouselTemplate,
378 + createFlex,
379 +};
380 +
381 +export default Line;
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.