
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
javascript全局变量控制
npm install --save hey-global
直接使用script标签引用js文件,可以通过github下载,引用build/global.js文件
使用的时候,直接引用G变量
G.set('GENDER', {
1: '先生',
2: '女士',
})
一般使用hey-global的时候,我们建议定义成全局变量G,如果你使用的是webpack,可以做如下配置:
new webpack.ProvidePlugin({
G: 'hey-global'
});
import G from 'hey-global';
// 如果是js直接引用的话,直接引用G变量
// 或者直接配置webpack全局变量,则无需引用
G.set('GENDER', {
1: '先生',
2: '女士',
})
// 存储用户信息
G.set('Account', {});
// 存储用户权限
G.set('Admin', true);
// 存储环境变量
G.set('env', {
fileOs: 'http://www.download.com',
socketOs: 'ws://www.socket.com',
});
const gender = G.get('GENDER')
// {
// 1: '先生',
// 2: '女士',
// }
// 获取用户信息
const account = G.get('Account');
// {}
// 获取用户权限
const isAdmin = G.get('Admin');
// true
// 获取环境变量
const env = G.get('env');
// {
// fileOs: 'http://www.download.com',
// socketOs: 'ws://www.socket.com',
// }
let todoTrigger = G.addlistener('NEW_TODO', (data)=>{
console.log(`new todo: ${date.message}`)
});
G.trigger('NEW_TODO', {message: 'go home'});
// new todo: go home
当无需处理的时候,可以通过removelistener删除监听
G.removelistener(todoTrigger);
FAQs
global.js, global, js
The npm package hey-global receives a total of 10 weekly downloads. As such, hey-global popularity was classified as not popular.
We found that hey-global 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
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.