corexxx 1.0.38 → 1.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dtime.d.ts +1 -1
- package/dist/dtime.js +23 -9
- package/dist/dtime.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/rss.d.ts +0 -12
- package/dist/rss.js +44 -46
- package/dist/rss.js.map +1 -1
- package/package.json +1 -2
- package/src/dtime.ts +22 -8
- package/src/index.ts +1 -1
- package/src/rss.ts +8 -6
package/dist/dtime.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export declare namespace dtime {
|
|
2
2
|
function getCurrentDate(): string;
|
|
3
3
|
function getDataFromString(str: string): void;
|
|
4
|
-
function getAgoString(str: string): "sometime" | undefined;
|
|
5
4
|
function getFormattedDate(str: string): string;
|
|
6
5
|
function isSameDay(day1: string, day2: string): boolean;
|
|
7
6
|
function fromNow(str: string): string;
|
|
@@ -9,4 +8,5 @@ export declare namespace dtime {
|
|
|
9
8
|
function throwIfPastDate(date: Date, error?: string): void;
|
|
10
9
|
function getDateOnlyFromISO(str: string): string;
|
|
11
10
|
function getTimeOnlyFromISO(str: string): string;
|
|
11
|
+
function getAgoString(dateISOString: string): string;
|
|
12
12
|
}
|
package/dist/dtime.js
CHANGED
|
@@ -6,6 +6,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.dtime = void 0;
|
|
8
8
|
const moment_1 = __importDefault(require("moment"));
|
|
9
|
+
const dlog_1 = require("./dlog");
|
|
9
10
|
var dtime;
|
|
10
11
|
(function (dtime) {
|
|
11
12
|
function getCurrentDate() {
|
|
@@ -16,15 +17,6 @@ var dtime;
|
|
|
16
17
|
new Date(str);
|
|
17
18
|
}
|
|
18
19
|
dtime.getDataFromString = getDataFromString;
|
|
19
|
-
function getAgoString(str) {
|
|
20
|
-
try {
|
|
21
|
-
//return timeAgo.format(new Date(str));
|
|
22
|
-
}
|
|
23
|
-
catch (ee) {
|
|
24
|
-
return "sometime";
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
dtime.getAgoString = getAgoString;
|
|
28
20
|
function getFormattedDate(str) {
|
|
29
21
|
try {
|
|
30
22
|
let d = new Date(str);
|
|
@@ -78,5 +70,27 @@ var dtime;
|
|
|
78
70
|
}
|
|
79
71
|
}
|
|
80
72
|
dtime.getTimeOnlyFromISO = getTimeOnlyFromISO;
|
|
73
|
+
const intervals = [
|
|
74
|
+
{ label: "year", seconds: 31536000 },
|
|
75
|
+
{ label: "month", seconds: 2592000 },
|
|
76
|
+
{ label: "day", seconds: 86400 },
|
|
77
|
+
{ label: "hour", seconds: 3600 },
|
|
78
|
+
{ label: "minute", seconds: 60 },
|
|
79
|
+
{ label: "second", seconds: 1 },
|
|
80
|
+
];
|
|
81
|
+
function getAgoString(dateISOString) {
|
|
82
|
+
try {
|
|
83
|
+
let date = new Date(dateISOString);
|
|
84
|
+
const seconds = Math.floor((Date.now() - date.getTime()) / 1000);
|
|
85
|
+
const interval = intervals.find((i) => i.seconds < seconds);
|
|
86
|
+
const count = Math.floor(seconds / interval.seconds);
|
|
87
|
+
return `${count} ${interval.label}${count !== 1 ? "s" : ""} ago`;
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
dlog_1.dlog.ex(e);
|
|
91
|
+
return "";
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
dtime.getAgoString = getAgoString;
|
|
81
95
|
})(dtime = exports.dtime || (exports.dtime = {}));
|
|
82
96
|
//# sourceMappingURL=dtime.js.map
|
package/dist/dtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dtime.js","sourceRoot":"","sources":["../src/dtime.ts"],"names":[],"mappings":";AAAA,iDAAiD;;;;;;AAEjD,oDAA4B;
|
|
1
|
+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AAI,GAAG,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC;YACnC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YACjE,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC;YAC5D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,QAAU,CAAC,OAAO,CAAC,CAAC;YACvD,OAAO,GAAG,KAAK,IAAI,QAAU,CAAC,KAAK,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;SACpE;QAAC,OAAO,CAAC,EAAE;YACV,WAAI,CAAC,EAAE,CAAC,CAAU,CAAC,CAAC;YACpB,OAAO,EAAE,CAAC;SACX;IACH,CAAC;IAXe,kBAAY,eAW3B,CAAA;AACH,CAAC,EA5EgB,KAAK,GAAL,aAAK,KAAL,aAAK,QA4ErB"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -23,6 +23,6 @@ __exportStar(require("./dtime"), exports);
|
|
|
23
23
|
__exportStar(require("./dtypes"), exports);
|
|
24
24
|
__exportStar(require("./dutils"), exports);
|
|
25
25
|
__exportStar(require("./dvalidation"), exports);
|
|
26
|
-
|
|
26
|
+
// export * from "./rss";
|
|
27
27
|
__exportStar(require("./yahoofin"), exports);
|
|
28
28
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAA8C;AAC9C,4CAA0B;AAC1B,4CAA0B;AAC1B,+CAA6B;AAC7B,4CAA0B;AAC1B,2CAAyB;AACzB,yCAAuB;AACvB,6CAA2B;AAC3B,4CAA0B;AAC1B,0CAAwB;AACxB,2CAAyB;AACzB,2CAAyB;AACzB,gDAA8B;AAC9B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAA8C;AAC9C,4CAA0B;AAC1B,4CAA0B;AAC1B,+CAA6B;AAC7B,4CAA0B;AAC1B,2CAAyB;AACzB,yCAAuB;AACvB,6CAA2B;AAC3B,4CAA0B;AAC1B,0CAAwB;AACxB,2CAAyB;AACzB,2CAAyB;AACzB,gDAA8B;AAC9B,yBAAyB;AACzB,6CAA2B"}
|
package/dist/rss.d.ts
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { TObject } from ".";
|
|
2
|
-
export declare namespace drss {
|
|
3
|
-
type TRssItem = {
|
|
4
|
-
title: string;
|
|
5
|
-
url: string;
|
|
6
|
-
contentSnippet?: string;
|
|
7
|
-
date: Date;
|
|
8
|
-
image?: string;
|
|
9
|
-
source?: string;
|
|
10
|
-
};
|
|
11
|
-
function getRSSFeed(url: string, mapper?: TObject): Promise<TRssItem[]>;
|
|
12
|
-
}
|
package/dist/rss.js
CHANGED
|
@@ -1,49 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
image: u[mapper1.image],
|
|
36
|
-
source: u[mapper1.source],
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return result;
|
|
40
|
-
});
|
|
2
|
+
/*import { dlog, dnetwork, TObject } from ".";
|
|
3
|
+
/// ISSUE with nodejs http and https
|
|
4
|
+
const xml2js = require("xml2js");
|
|
5
|
+
export namespace drss {
|
|
6
|
+
export type TRssItem = {
|
|
7
|
+
title: string;
|
|
8
|
+
url: string;
|
|
9
|
+
contentSnippet?: string;
|
|
10
|
+
date: Date;
|
|
11
|
+
image?: string;
|
|
12
|
+
source?: string;
|
|
13
|
+
};
|
|
14
|
+
export async function getRSSFeed(url: string, mapper?: TObject): Promise<TRssItem[]> {
|
|
15
|
+
let feed = await dnetwork.get(url);
|
|
16
|
+
let data = await xml2js.parseStringPromise(feed, { mergeAttrs: true });
|
|
17
|
+
let mapper1: TObject = {
|
|
18
|
+
date: "isoDate",
|
|
19
|
+
title: "title",
|
|
20
|
+
contentSnippet: "contentSnippet",
|
|
21
|
+
url: "link",
|
|
22
|
+
image: "image",
|
|
23
|
+
source: "creator",
|
|
24
|
+
};
|
|
25
|
+
let result: TRssItem[] = [];
|
|
26
|
+
for (let u of feed.items) {
|
|
27
|
+
result.push({
|
|
28
|
+
title: u[mapper1.title] as string,
|
|
29
|
+
url: u[mapper1.url] as string,
|
|
30
|
+
contentSnippet: u[mapper1.contentSnippet] as string,
|
|
31
|
+
date: new Date(u[mapper1.date]),
|
|
32
|
+
image: u[mapper1.image] as string,
|
|
33
|
+
source: u[mapper1.source] as string,
|
|
34
|
+
});
|
|
41
35
|
}
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
(async () => {
|
|
41
|
+
dlog.obj(await drss.getRSSFeed("https://www.zeebiz.com/world-economy.xml"));
|
|
42
|
+
//dlog.obj(await drss.getRSSFeed("http://feeds.marketwatch.com/marketwatch/topstories/"));
|
|
43
|
+
//dlog.obj(await drss.getRSSFeed("https://www.moneycontrol.com/rss/MCtopnews.xml"));
|
|
44
|
+
})();
|
|
45
|
+
// issue with NODEJS
|
|
46
|
+
*/
|
|
49
47
|
//# sourceMappingURL=rss.js.map
|
package/dist/rss.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rss.js","sourceRoot":"","sources":["../src/rss.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rss.js","sourceRoot":"","sources":["../src/rss.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4CE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corexxx",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.42",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
"axios": "^0.21.1",
|
|
18
18
|
"moment": "^2.29.1",
|
|
19
19
|
"nse-indices": "^0.0.3",
|
|
20
|
-
"rss-parser": "^3.12.0",
|
|
21
20
|
"underscore": "^1.13.1",
|
|
22
21
|
"universal-cookie": "^4.0.4"
|
|
23
22
|
},
|
package/src/dtime.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
//import en from "javascript-time-ago/locale/en";
|
|
2
2
|
|
|
3
3
|
import moment from "moment";
|
|
4
|
+
import { dlog } from "./dlog";
|
|
4
5
|
|
|
5
6
|
export namespace dtime {
|
|
6
7
|
export function getCurrentDate() {
|
|
@@ -11,14 +12,6 @@ export namespace dtime {
|
|
|
11
12
|
new Date(str);
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
export function getAgoString(str: string) {
|
|
15
|
-
try {
|
|
16
|
-
//return timeAgo.format(new Date(str));
|
|
17
|
-
} catch (ee) {
|
|
18
|
-
return "sometime";
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
15
|
export function getFormattedDate(str: string) {
|
|
23
16
|
try {
|
|
24
17
|
let d = new Date(str);
|
|
@@ -65,4 +58,25 @@ export namespace dtime {
|
|
|
65
58
|
return "Unknown Time";
|
|
66
59
|
}
|
|
67
60
|
}
|
|
61
|
+
const intervals = [
|
|
62
|
+
{ label: "year", seconds: 31536000 },
|
|
63
|
+
{ label: "month", seconds: 2592000 },
|
|
64
|
+
{ label: "day", seconds: 86400 },
|
|
65
|
+
{ label: "hour", seconds: 3600 },
|
|
66
|
+
{ label: "minute", seconds: 60 },
|
|
67
|
+
{ label: "second", seconds: 1 },
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
export function getAgoString(dateISOString: string) {
|
|
71
|
+
try {
|
|
72
|
+
let date = new Date(dateISOString);
|
|
73
|
+
const seconds = Math.floor((Date.now() - date.getTime()) / 1000);
|
|
74
|
+
const interval = intervals.find((i) => i.seconds < seconds);
|
|
75
|
+
const count = Math.floor(seconds / interval!!.seconds);
|
|
76
|
+
return `${count} ${interval!!.label}${count !== 1 ? "s" : ""} ago`;
|
|
77
|
+
} catch (e) {
|
|
78
|
+
dlog.ex(e as Error);
|
|
79
|
+
return "";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
68
82
|
}
|
package/src/index.ts
CHANGED
package/src/rss.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { TObject } from ".";
|
|
2
|
-
|
|
1
|
+
/*import { dlog, dnetwork, TObject } from ".";
|
|
2
|
+
/// ISSUE with nodejs http and https
|
|
3
|
+
const xml2js = require("xml2js");
|
|
3
4
|
export namespace drss {
|
|
4
5
|
export type TRssItem = {
|
|
5
6
|
title: string;
|
|
@@ -10,9 +11,8 @@ export namespace drss {
|
|
|
10
11
|
source?: string;
|
|
11
12
|
};
|
|
12
13
|
export async function getRSSFeed(url: string, mapper?: TObject): Promise<TRssItem[]> {
|
|
13
|
-
let
|
|
14
|
-
let
|
|
15
|
-
let feed = await parser.parseURL(url);
|
|
14
|
+
let feed = await dnetwork.get(url);
|
|
15
|
+
let data = await xml2js.parseStringPromise(feed, { mergeAttrs: true });
|
|
16
16
|
let mapper1: TObject = {
|
|
17
17
|
date: "isoDate",
|
|
18
18
|
title: "title",
|
|
@@ -37,7 +37,9 @@ export namespace drss {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
(async () => {
|
|
40
|
-
|
|
40
|
+
dlog.obj(await drss.getRSSFeed("https://www.zeebiz.com/world-economy.xml"));
|
|
41
41
|
//dlog.obj(await drss.getRSSFeed("http://feeds.marketwatch.com/marketwatch/topstories/"));
|
|
42
42
|
//dlog.obj(await drss.getRSSFeed("https://www.moneycontrol.com/rss/MCtopnews.xml"));
|
|
43
43
|
})();
|
|
44
|
+
// issue with NODEJS
|
|
45
|
+
*/
|