Socket
Book a DemoInstallSign in
Socket

simple-const

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-const

常量定义

latest
Source
npmnpm
Version
1.2.0
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

constant

安装

npm安装

$ npm install simple-const

或者使用yarn

$ yarn add simple-const

使用

import constant, {parse} from 'simple-const'

//直接给constant赋值
constant.const_name = 'const_value';

//取值
console.log(constant.const_name); // const_value

// 不可以重复赋值
constant.const_name = 'new value'; // not change

// 不可以delete
delete constant.const_name; // false

// 通过defineProperty或者defineProperties修改不生效
Object.defineProperty(constant, 'const_name', {
  value: 'new value'
});
console.log(constant.const_name); // const_value



// 通过parse解析键值对常量
parse({
  new_const: 'new value'
});

console.log(constant.new_const); // new value

Keywords

proxy

FAQs

Package last updated on 23 Mar 2020

Did you know?

Socket

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.

Install

Related posts