
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
@lsky/preset-data
Advanced tools
在编译期,在项目中,预设数据。
$ yarn add @lsky/preset-data
loader在
babel-loader处增加PresetDataLoader
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: [
"babel-loader",
{
loader: "@lsky/preset-data/loader",
},
],
},
pluginconst PresetDataPlugin = require("@lsky/preset-data/plugin")
plugins: [
new PresetDataPlugin([
{
name: "jobs", // 必须参数
// -------
// fetch 请求参数请参照 axios 配置
url: "http://localhost:8030/test", // required
method: "get",
//-------
cb: (data) => {
// axios response data
// must return data
return data.data
},
},
]),
new HtmlWebPackPlugin({
template: path.resolve(__dirname, "../index.ejs"),
filename: path.resolve(__dirname, "../dist/index.html"),
}),
],
PresetDataPlugin 使用说明interface Option extends axios.AxiosRequestConfig {
name: string;
cb?: (responseData: any) => data:any;
raw?: any;
}
new PresetDataPlugin(options: (Option | Option[]))
| Name | Type | Default | Description |
|---|---|---|---|
| name | string | null | 预设数据名称,用于项目中取值。注意,该字段必填。 |
| cb | function | null | 处理数据 |
| raw | any | null | 如设置了 raw,将不通过 request 获取数据。注意,该优先级较高。 |
import presetDataFunc from "@lsky/preset-data"
console.log(presetDataFunc("jobs")) // 参数是 plugin 的 name
console.log(presetDataFunc())
FAQs
> 在编译期,在项目中,预设数据。
The npm package @lsky/preset-data receives a total of 3 weekly downloads. As such, @lsky/preset-data popularity was classified as not popular.
We found that @lsky/preset-data 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
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.