New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More β†’
Socket
Sign inDemoInstall
Socket

capsulable

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

capsulable - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

4

index.js

@@ -39,5 +39,7 @@ const Field = require('./src/initialize')

// Configure encapsulated class.
return Capsulable(Origin, Field())
let mode = undefined
if(typeof inherit == 'string') mode = inherit
return Capsulable(Origin, Field(), mode)
}
module.exports = Capsulator
{
"name": "capsulable",
"version": "1.0.0",
"version": "1.1.0",
"description": "A module that helps developers easily encapsulate classes in nodejs.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -10,3 +10,3 @@ ## Capsulable

μΊ‘μŠλŸ¬λΈ” λͺ¨λ“ˆμ€ μžλ°”μŠ€ν¬λ¦½νŠΈ ν΄λž˜μŠ€μ—μ„œ μ‰½κ²Œ μ ‘κ·Όμ œν•œμž κ°œλ…μ„ μ‚¬μš©ν•  수 있게 λ•μŠ΅λ‹ˆλ‹€. ν΄λ‘œμ € λ³€μˆ˜ κ°œλ…μ„ 톡해 μΊ‘μŠν™” 및 은닉화 κ°œλ…μ„ κ΅¬ν˜„ν•©λ‹ˆλ‹€.
μΊ‘μŠλŸ¬λΈ” λͺ¨λ“ˆμ€ μžλ°”μŠ€ν¬λ¦½νŠΈ ν΄λž˜μŠ€μ—μ„œ μ‰½κ²Œ μ ‘κ·Όμ œν•œμž κ°œλ…μ„ μ‚¬μš©ν•  수 있게 λ•μŠ΅λ‹ˆλ‹€. ν΄λ‘œμ € κ°œλ…μ„ 톡해 μΊ‘μŠν™” 및 은닉화 κ°œλ…μ„ κ΅¬ν˜„ν•©λ‹ˆλ‹€.

@@ -33,3 +33,3 @@ ## μ„€μΉ˜λ°©λ²•

Capsulable 은 `class` 의 `constructor` ν•¨μˆ˜λ₯Ό ν†΅ν•΄μ„œ 데이터 ν•„λ“œλ₯Ό κ³΅μœ ν•©λ‹ˆλ‹€. (μ΄λŠ” 즉 Capsulable 이 μ΅œμ’…μ μœΌλ‘œ 항상 μžμ‹ 클래슀둜 ꡬ성 됨을 μ˜λ―Έν•©λ‹ˆλ‹€.) μΊ‘μŠν™” ν•˜κΈΈ μ›ν•˜λŠ” ν΄λž˜μŠ€λŠ” 사전에 Capsulable 을 ν†΅ν•΄μ„œ coonstructr μ—μ„œ 데이터 ν•„λ“œλ₯Ό 상속 λ°›μ•„μ•Όν•©λ‹ˆλ‹€. μ˜ˆμ‹œ 상 문법은 ES5둜 ν‘œκΈ°λ˜λ‚˜, Babel을 ν†΅ν•œ ES6 λ¬Έλ²•μœΌλ‘œ κ΅¬ν˜„ν•΄λ„ λ©λ‹ˆλ‹€.
Capsulable 은 `class` 의 `constructor` ν•¨μˆ˜λ₯Ό ν†΅ν•΄μ„œ 데이터 ν•„λ“œλ₯Ό κ³΅μœ ν•©λ‹ˆλ‹€. (μ΄λŠ” 즉 Capsulable 이 μ΅œμ’…μ μœΌλ‘œ 항상 μžμ‹ 클래슀둜 ꡬ성 됨을 μ˜λ―Έν•©λ‹ˆλ‹€.) μΊ‘μŠν™” ν•˜κΈΈ μ›ν•˜λŠ” ν΄λž˜μŠ€λŠ” 사전에 Capsulable 을 ν†΅ν•΄μ„œ constructor μ—μ„œ 데이터 ν•„λ“œλ₯Ό 상속 λ°›μ•„μ•Όν•©λ‹ˆλ‹€. μ˜ˆμ‹œ 상 문법은 ES5둜 ν‘œκΈ°λ˜λ‚˜, Babel을 ν†΅ν•œ ES6 λ¬Έλ²•μœΌλ‘œ κ΅¬ν˜„ν•΄λ„ λ©λ‹ˆλ‹€.

@@ -274,2 +274,22 @@ ### 클래슀 μ •μ˜ 예제

## Final Class κ΅¬ν˜„
클래슀 μ›ν˜•μ˜ μΊ‘μŠν™” 이후 νŒŒμƒ 클래슀λ₯Ό 더 이상 λ§Œλ“€κΈΈ μ›μΉ˜ μ•ŠλŠ” 경우 Capsulable ν•¨μˆ˜ μ‚¬μš©μ‹œ 2번째 인자둜 final λͺ¨λ“œλ₯Ό μ μš©μ‹œν‚΄μœΌλ‘œμ¨ νŒŒμƒ ν΄λž˜μŠ€μ™€ 데이터 ν•„λ“œλ₯Ό κ³΅μœ ν•˜μ§€ μ•Šλ„λ‘ ν•  수 μžˆμŠ΅λ‹ˆλ‹€. (클래슀의 νŒŒμƒμ„ μ™„μ „νžˆ λ§‰μ§€λŠ” λͺ»ν•˜λ‚˜, 데이터 ν•„λ“œκ°€ κ³΅μœ λ˜λŠ” 것을 막을 μˆ˜λŠ” μžˆμŠ΅λ‹ˆλ‹€.)
```js
// index.js
const Capsulable = require('./capsulable')
const A = require('./A')
// 2번째 인자둜 final을 적으면
// νŒŒμƒν΄λž˜μŠ€μ™€ 데이터 ν•„λ“œλ₯Ό κ³΅μœ ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.
const SharedA = Capsulable(A, 'final')
// μΊ‘μŠν™” 된 클래슀λ₯Ό ν†΅ν•΄μ„œ
// μΈμŠ€ν„΄μŠ€λ₯Ό 생성할 수 μžˆμŠ΅λ‹ˆλ‹€.
let sharedA = new SharedA()
```
--------------------------------------
## μž‘μ—… λͺ©λ‘

@@ -288,5 +308,6 @@

- [x] assert κ°€λ³€λͺ¨λ“ˆν™” ν•˜μ—¬ 쒅속성 μ™„μ „ 배제 κ΅¬ν˜„
- [x] final 클래슀 κ΅¬ν˜„
- [ ] final λ³€μˆ˜ κ΅¬ν˜„
- [ ] μΊ‘μŠν™” 된 클래슀의 constructor κ°€λ³€λ³€μˆ˜ 인자 κ΅¬ν˜„
- [ ] μΊ‘μŠν™” 된 클래슀의 constructor κ°€λ³€λ³€μˆ˜μ˜ νŒŒμƒν΄λž˜μŠ€ 곡유 κ΅¬ν˜„
- [ ] final ν‚€μ›Œλ“œ κΈ°λŠ₯ κ΅¬ν˜„
--------------------------------------

@@ -293,0 +314,0 @@

@@ -11,3 +11,3 @@ ## Capsulable

Encapsulated modules help you use the concept of access limiting in JavaScript classes. Implement the concepts of encapsulation and concealment through the concept of closure variables.
Encapsulated modules help you use the concept of access limiting in JavaScript classes. Implement the concepts of encapsulation and concealment through the concept of closure.

@@ -37,3 +37,3 @@

Capable shares the data field through the `constructor` function of `class`. (This means that the Capable is ultimately always composed of child classes.) Classes that want to be encapsulated must inherit the data fields from the Coonstructr through the Capsulable in advance. Examples of grammar are marked as ES5, but can be implemented using ES6 via the Babel.
Capable shares the data field through the `constructor` function of `class`. (This means that the Capable is ultimately always composed of child classes.) Classes that want to be encapsulated must inherit the data fields from the constructor through the Capsulable in advance. Examples of grammar are marked as ES5, but can be implemented using ES6 via the Babel.

@@ -273,2 +273,21 @@ ### Example of class definition

## Implement Final Class
If you no longer want to create a derived class after the encapsulation of a class prototype, you can use the Capsulable function to apply final mode as a second factor to avoid sharing derived classes and data fields. (This does not completely block a class from being derived, but can prevent data fields from being shared.)
```js
// index.js
const Capsulable = require('./capsulable')
const A = require('./A')
// If you write final in the second parameter,
// the derived class and the data fields are not shared.
const SharedA = Capsulable(A, 'final')
// Can create instances through encapsulated classes.
let sharedA = new SharedA()
```
--------------------------------------
## Worklist

@@ -287,5 +306,6 @@

- [x] Implement complete exclusion of dependencies by modularizing asset
- [x] Implement final class
- [ ] Implement final variable
- [ ] Implementing the constructor variable variable factor of the encapsulated class
- [ ] Implementing derivative class sharing with constructor variable of encapsulated class
- [ ] Implement final keyword function
--------------------------------------

@@ -292,0 +312,0 @@

@@ -7,3 +7,3 @@ /**

*/
module.exports = (Origin, Protect)=>{
module.exports = (Origin, Protect, mode)=>{
return class Capsulable extends Origin {

@@ -13,2 +13,10 @@ constructor(inherit){

super(Field)
// When in final mode,
// the data field is
// not passed to the child class.
if(typeof mode == 'string'
&& mode.toLowerCase() == 'final')
return
if(typeof inherit === 'object')

@@ -15,0 +23,0 @@ if(new.target != this.constructor.name)

@@ -79,2 +79,16 @@ const assert = require('assert')

UnitTest(packB, packC)
// Final mode Test
let FinalClass = Capsulable(A, 'final')
class FailureClass extends FinalClass{
constructor(inherit){
let hook = {}
super(hook)
assert(typeof hook['field'] === 'undefined')
// Field(this, hook.field)
// if(inherit) Capsulable(hook, inherit)
}
}
new FailureClass()
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc