melon-chart-api
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -10,2 +10,3 @@ const queryString = require('querystring'); | ||
const isFuture = require('date-fns/is_future'); | ||
const isValid = require('date-fns/is_valid'); | ||
const subMonths = require('date-fns/sub_months'); | ||
@@ -23,6 +24,15 @@ const formatDate = require('date-fns/format'); | ||
// and the beginning of Epoch time if null. | ||
const dateObj = parseDate(date === null || isFuture(date) ? Date() : date); | ||
const dateObj = parseDate(date === null || !isValid(parseDate(date)) || isFuture(date) ? Date() : date); | ||
const format = 'YYYYMMDD'; | ||
return { | ||
realtime() { | ||
const realtimeFormat = format + 'HH'; | ||
const startDate = dateObj; | ||
const endDate = dateObj; | ||
return { | ||
start: formatDate(startDate, realtimeFormat), | ||
end: formatDate(endDate, realtimeFormat), | ||
}; | ||
}, | ||
daily() { | ||
@@ -78,2 +88,9 @@ const startDate = dateObj; | ||
decoded[options.movedKey] = 'Y'; | ||
if (period === 'realtime') { | ||
url = options.url.replace('day/', ''); | ||
decoded[options.movedKey] = 'N'; | ||
if (options.realtime) { | ||
decoded[options.dayTime] = dates.start.toString(); | ||
} | ||
} | ||
if (period === 'week') { | ||
@@ -80,0 +97,0 @@ url = options.url.replace('day', 'week'); |
@@ -16,2 +16,8 @@ const populateOptions = require('./defaults'); | ||
return { | ||
realtime() { | ||
const dates = dateManager.realtime(); | ||
const period = 'realtime'; | ||
const url = composeUrl(period, dates, opts); | ||
return scrapeMelon(url, dates, opts); | ||
}, | ||
daily() { | ||
@@ -18,0 +24,0 @@ // NOTE: Dates are not needed for daily chart |
{ | ||
"name": "melon-chart-api", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Melon Music Chart API", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/hyunchel/melon-chart-api", |
@@ -84,2 +84,8 @@ # Melon Chart API | ||
##### realtime | ||
Type: `boolean` | ||
Default: `false` | ||
### methods | ||
@@ -89,2 +95,9 @@ | ||
#### Melon.realtime() | ||
Returns realtime chart. | ||
This method will default to the latest "realtime" chart rankings. | ||
With `realtime` flag, the given date will be treated as "realtime", and will expect "hour" to be populated in the date. | ||
If "hour" is not populated, it defaults to midnight(`00`). | ||
#### Melon.daily() | ||
@@ -91,0 +104,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
104155
19
967
116