Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
VERSION 2.0.2
私人用
日记以文件的形式存储在磁盘上,本库用于方便的读取此文件为某种 JS 对象。
这是 Daily 的标准形式:
json { | => 这里是 Meta 元信息
"title": "hello" |
} |
;;;;;; | => 用六个分号分隔开
|
# Content | => 此处是正文, 可以书写 Markdown
|
Last day, Good Morning |
|
|
三大要素:
注, 分隔符本身占用了字符串
;;;;;;
,因此请勿在 Meta 里出现该分隔符,否则会造成解析的失败
可以看到 Daily 都会带一个 Meta 放在头部用来 记录
Daily 的元信息,为了方便阅读和程序读取的方便,可以采用 JSON 方式进行存储。
json {
"title": "漫语三月",
"time": "2018年3月25日 02:02",
"from": "a@b.com",
"to": "c@d.com",
"theme": "pure"
}
当然,可以使用其他方式处理,要采用其他方式,仅需如此编写:
daily {
title: 漫语三月
time: 2018年3月25日 02:02
from: a@b.com
to: c@d.com
theme: pure
}
这两段的第一行的不同,让本解析器采取了不同的方式解析。此处的 json
或者 daily
叫做解析器选择器,受 CSS 选择器的启发。
推荐使用 daily 作为解析器选择器,比 JSON 好读一些,写起来也省些事
Meta 中目前可以使用的字段
title
* 标题time
* 时间from
来自于to
发送到theme
主题注: 带 * 的为必填字段
先安装
$ npm i md.daily
使用方法
const { Daily } = require('md.daily');
let daily = new Daily('path/to/your/daily.md');
daily.getData().then(daily => {
// 此处的 daily 和外面的 daily 是同一个引用
console.log(daily.meta);
}).catch(err => {
console.log(err);
});
更多使用,参见 使用法
在实际应用里,更多的情况是 Daily 都放在目录里,为此引入 Pool 类针对这种情况进行编程。
const { Pool } = require('md.daily');
const my_daily_diretory = '/home/eczn/dailys';
const pool = new Pool(my_daily_diretory);
// 拉取文件夹内部全部 dailys
pool.pull().then(console.log);
除却 pull()
之外,Pool 还实现了很多特性:
.md
文件的 Daily 实例。add
unlink
change
参数是对应的 Daily 实例更多请参考源码实现,或者函数签名。
MIT
FAQs
for daily store
The npm package md.daily receives a total of 1 weekly downloads. As such, md.daily popularity was classified as not popular.
We found that md.daily demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.