Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-mvc-framework

Package Overview
Dependencies
Maintainers
0
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-mvc-framework - npm Package Compare versions

Comparing version 1.0.16 to 1.0.17

demonstrament/localhost/tests/MVC/001/object/assign/index.js

8

demonstrament/localhost/tests/MVC/000/DETObjectVentilation/index.js

@@ -10,6 +10,6 @@ import objectAssign from './assign/index.js'

objectAssign()
objectDefineProperties()
objectDefineProperty()
objectFreeze()
objectSeal()
// objectDefineProperties()
// objectDefineProperty()
// objectFreeze()
// objectSeal()
}

@@ -7,5 +7,5 @@ import DETObjectInstantiation from './DETObjectInstantiation/index.js'

DETObjectVentilation()
DETArrayVentilation()
// DETArrayVentilation()
}
document.addEventListener('DOMContentLoaded', DOMContentLoaded)

@@ -1,40 +0,4 @@

import { DET } from '/dependencies/mvc-framework.js'
import logEvent from './logEvent.js'
import objectAssignDemonstration from './object/assign/index.js'
function DOMContentLoaded() {
console.log('-----')
const object = new DET({
aaa: 111,
bbb: 222,
ccc: {
ddd: 444,
eee: 555,
fff: {
ggg: 777
}
}
})
console.log(object.parse())
object.addEventListener('assign', logEvent)
// object.addEventListener('assignSource', logEvent)
// object.addEventListener('assignSourceProperty', logEvent)
object.assign({
ccc: {
fff: {
ggg: 777777,
hhh: {
iii: 999
}
}
}
})
// console.log('-----')
// object.assign({
// ccc: {
// fff: {
// hhh: {
// iii: 999999
// }
// }
// }
// })
objectAssignDemonstration()
}

@@ -41,0 +5,0 @@

@@ -1,150 +0,40 @@

import { FetchRouter, Model, View } from '/dependencies/mvc-framework.js'
import { DETEventLog } from '../Coutil/index.js'
import { DET } from '/dependencies/mvc-framework.js'
function DOMContentLoaded() {
// Photos View
const photosView = new View({
parentElement: document.querySelector('app'),
selectors: {
photosControl: 'photos-control',
photosControlButton: 'photos-control > button',
photos: 'photos',
photo: 'photos > photo',
},
events: {
'render': function photosViewRender($event) {
this.parentElement.replaceChildren(
...this.element.content.children
)
},
'selectors.photosControlButton click': function photosControlButtonClick($event) {
const crement = Number($event.target.getAttribute('data-crement'))
photosModel.content.assign({ currentIndex: crement })
},
},
templates: {
// Image Template
img: function imgTemplate($img) {
return `<img src="${
$img.src
}" alt="${
$img.alt
}" width="${
$img.width
}" height="${
$img.height
}" />`
},
// Photo Template
photo: function photoTemplate($photo, $active) {
let template
if($active === false) {
template = `<photo>${
this.templates.img($photo.img)
}</photo>`
} else if($active === true){
template = `<photo data-active="${$active}">${
this.templates.img($photo.img)
}</photo>`
} else {
template = ``
}
return template
},
// Photos Template
photos: function photosTemplate($photos) {
return `<photos>${
$photos.map(
($photo, $photoIndex) => this.templates.photo($photo, (
$photos.currentIndex === $photoIndex
))
).join('\n')
}</photos>`
},
// Photos Control Template
photosControl: function photosControlTemplate($photosControl) {
return `<photos-control>
<button data-crement="-1">&lt;PRE</button>
<button data-crement="1">ANT&gt;</button>
</photos-control>`
},
// Default Template
default: function defaultTemplate($photosContent) {
return [
this.templates.photosControl($photosContent),
this.templates.photos($photosContent),
].join('\n')
},
},
//
}, { enable: true })
const photosModel = new Model({
content: [],
events: {
'content push': function photosPush($event) {
photosView.renderElement({
name: 'default',
data: photosModel.content,
})
},
'setCurrentIndex': function setCurrentIndex($event) {
const { currentIndex } = $event.detail
let photoIndex = 0
for(const $photo of photosView.selectors.photo) {
if(photoIndex === currentIndex) {
$photo.setAttribute('data-active', true)
} else if($photo.hasAttribute('data-active')) {
$photo.removeAttribute('data-active')
}
photoIndex++
}
},
},
// const object = new DET({
// aaa: 111,
// bbb: 222,
// ccc: {
// ddd: 444,
// eee: 555,
// fff: [
// 777, 888, [{
// zzz: [999, 888, 777]
// }]
// ]
// }
// })
const object = new DET({
aaa: {
bbb: 222,
},
} )
// object.aaa.addEventListener('set', DETEventLog)
object.addEventListener('set', DETEventLog)
object.aaa.bbb = 222222
object.ccc = 3456
object.addEventListener('assign', DETEventLog)
object.aaa.assign({
bbb: 111
})
photosModel.content.defineProperties({
'_currentIndex': {
enumerable: false,
writable: true,
value: 0,
},
'currentIndex': {
enumerable: false,
get() { return this._currentIndex },
set($crement) {
let { currentIndex } = photosModel.content
if(currentIndex + $crement >= photosModel.content.length) {
currentIndex = 0
} else if(currentIndex + $crement <= -1) {
currentIndex = photosModel.content.length - 1
} else {
currentIndex += $crement
}
this._currentIndex = currentIndex
photosModel.dispatchEvent(new CustomEvent('setCurrentIndex', {
detail: { currentIndex },
}))
},
},
})
const fetchRouter = new FetchRouter({
scheme: 'http',
domain: 'demonstrament.mvc-framework',
port: 3000,
routes: {
'/services/photos': {
name: 'photos',
methods: {
get: {
method: 'get',
}
}
}
},
events: {
'routes.photos status': async function photosStatus($event) {
const photos = await $event.detail.json()
photosModel.content.push(...photos)
},
},
}, { enableEvents: true })
fetchRouter.routes.photos.get()
// console.log(object)
// console.log('object.aaa', object.aaa)
// console.log('object', object)
// const array = new DET([
// [0, 1, 2], [3, 4, 5]
// ])
// array[0][2] = 222
// console.log('array[0][2]', array[0][2])
// console.log('array', array)
}

@@ -151,0 +41,0 @@ document.addEventListener(

import { typeOf, propFromPropPath } from '../../../Coutil/index.js'
export default class Event {
export default class DynamicEventSystemEvent {
constructor($settings) {

@@ -4,0 +4,0 @@ this.settings = $settings

import { typeOf, parseShortenedEvents } from '../../Coutil/index.js'
import Event from './Event/index.js'
import DESEvent from './Event/index.js'
export default class DynamicEventSystem extends EventTarget {

@@ -48,3 +48,3 @@ constructor($events, $enable) {

})
_events.push(new Event($event))
_events.push(new DESEvent($event))
}

@@ -51,0 +51,0 @@ }

@@ -0,2 +1,5 @@

import { typeOf } from '../../../Coutil/index.js'
import DynamicEventTarget from '../index.js'
import DETEvent from '../DynamicEvent/index.js'
import DynamicEventBubble from '../DynamicEvent/DynamicEventBubble/index.js'
import Traps from './Traps/index.js'

@@ -6,24 +9,30 @@

#aliases
#options
traps
constructor($aliases, $options) {
this.#aliases = $aliases
this.#options = $options
this.traps = new Traps(this.#aliases, $options.traps)
return this
}
// Get
// Get Property
get get() {
const $this = this
const {
$type,
$eventTarget,
$root, $rootAlias,
$type, $proxy,
$root,
$rootAlias,
$basename,
$path,
} = this.#aliases
return function get($target, $property, $receiver) {
// 1. Root Alias
if($property === $rootAlias) return this
// Root Property
if($property === $rootAlias) {
return this.proxy
} else {
// Event Target/Dynamic Event Target Property
if(
// 2. Event Target Class Instance Methods
Object.getOwnPropertyNames(EventTarget.prototype)
.includes($property) ||
// 3. Dynamic Event Target Class Instance Methods
Object.getOwnPropertyNames(DynamicEventTarget.prototype)

@@ -38,56 +47,31 @@ .includes($property) /* ||

return $eventTarget[$property]
}
// 3.5. Root Alias Property
} else
// Object Property
if(
Object.getOwnPropertyNames($root)
Object.getOwnPropertyNames(Object)
.includes($property)
) {
return $root[$property]
}
// 4. Type Object
return $this.traps['Object'][$property]
} else
// Array Property
if(
$type === 'object'
Object.getOwnPropertyNames(Array.prototype)
.includes($property) ||
Object.getOwnPropertyNames(Array)
.includes($property)
) {
if(
Object.getOwnPropertyNames(Object)
.includes($property)
) {
return $this.traps['Object'][$property]
} else
if(
Object.getOwnPropertyNames(Array.prototype)
.includes($property) ||
Object.getOwnPropertyNames(Array)
.includes($property)
) {
return $this.traps['Array'][$property]
}
}
// 5. Type Array
return $this.traps['Array'][$property]
} /* else
// Map
if(
$type === 'array'
) {
if(
Object.getOwnPropertyNames(Array.prototype)
.includes($property) ||
Object.getOwnPropertyNames(Array)
.includes($property)
) {
return $this.traps['Array'][$property]
} else
if(
Object.getOwnPropertyNames(Object)
.includes($property)
) {
return $this.traps['Object'][$property]
}
}
// 6. Map Class Instance Property Trap
if(
$type === 'map' &&
Object.getOwnPropertyNames(Map.prototype)
.includes($property)
) return $this.traps['Map'][$property] ||
$this.traps['Map']['default']
return undefined
) {
return $this.traps['Map'][$property] ||
$this.traps['Map']['default']
} */
else
return $root[$property]
}
}

@@ -98,43 +82,71 @@ }

const {
$eventTarget, $root, $rootAlias, $type, $proxy
$type,
$eventTarget,
$root,
$rootAlias,
$basename,
$path,
} = this.#aliases
const { merge } = this.#options.traps.object.set
return function set($target, $property, $value, $receiver) {
// Object Property
if(
$type === 'object'
Object.getOwnPropertyNames(Object)
.includes($property)
) {
if(
Object.getOwnPropertyNames(Object)
.includes($property)
) {
$this.traps['Object'][$property] = $value
} else
if(
Object.getOwnPropertyNames(Array.prototype)
.includes($property) ||
Object.getOwnPropertyNames(Array)
.includes($property)
) {
$this.traps['Array'][$property] = $value
}
$this.traps['Object'][$property] = $value
} else
// Array, Array Prototype Property
if(
$type === 'array'
Object.getOwnPropertyNames(Array.prototype)
.includes($property) ||
Object.getOwnPropertyNames(Array)
.includes($property)
) {
if(
Object.getOwnPropertyNames(Array.prototype)
.includes($property) ||
Object.getOwnPropertyNames(Array)
.includes($property)
) {
$this.traps['Array'][$property] = $value
} else if(
Object.getOwnPropertyNames(Object)
.includes($property)
) {
$this.traps['Object'][$property] = $value
}
$this.traps['Array'][$property] = $value
} else
// Dynamic Event Target Property
if(
typeOf($value) === 'object' ||
typeOf($value) === 'array' /* ||
typeOf($value) === 'map' */
) {
$value = new DynamicEventTarget(
$value, {
$rootAlias,
$path: path,
$basename: basename,
$parent: $eventTarget
}
)
}
// Property Assignment
$root[$property] = $value
const basename = $property
// console.log('basename', basename)
const path = (
$path !== null
) ? $path.concat('.', $property)
: $property
// console.log('path', path)
$eventTarget.addEventListener(
'set', DynamicEventBubble
)
$eventTarget.dispatchEvent(
new DETEvent(
'set',
{
basename,
path,
detail: {
property: $property,
value: $value,
},
}
)
)
return true
}
}
get delete() {}
}

@@ -1,5 +0,3 @@

import {
DynamicEvent,
DynamicEventBubble,
} from '../../../Events/index.js'
import DETEvent from '../../../../../DynamicEvent/index.js'
import DETEventBubble from '../../../../../DynamicEvent/DynamicEventBubble/index.js'
export default function CopyWithin(

@@ -16,6 +14,6 @@ $trap, $trapPropertyName, $aliases

$eventTarget.addEventListener(
'copyWithin', DynamicEventBubble
'copyWithin', DETEventBubble
)
$eventTarget.addEventListener(
'copyWithinIndex', DynamicEventBubble
'copyWithinIndex', DETEventBubble
)

@@ -56,3 +54,3 @@ return Object.defineProperty(

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'copyWithinIndex',

@@ -76,3 +74,3 @@ {

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'copyWithin',

@@ -79,0 +77,0 @@ {

import { isDirectInstanceOf } from '../../Coutil/index.js'
import DynamicEventTarget from '../../../../../index.js'
import {
DynamicEvent,
DynamicEventBubble,
} from '../../../Events/index.js'
import DETEvent from '../../../../../DynamicEvent/index.js'
import DETEventBubble from '../../../../../DynamicEvent/DynamicEventBubble/index.js'
export default function Fill(

@@ -18,6 +16,6 @@ $trap, $trapPropertyName, $aliases

$eventTarget.addEventListener(
'fill', DynamicEventBubble
'fill', DETEventBubble
)
$eventTarget.addEventListener(
'fillIndex', DynamicEventBubble
'fillIndex', DETEventBubble
)

@@ -73,3 +71,3 @@ return Object.defineProperty(

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'fillIndex',

@@ -91,3 +89,3 @@ {

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'fill',

@@ -94,0 +92,0 @@ {

@@ -1,5 +0,3 @@

import {
DynamicEvent,
DynamicEventBubble,
} from '../../../Events/index.js'
import DETEvent from '../../../../../DynamicEvent/index.js'
import DETEventBubble from '../../../../../DynamicEvent/DynamicEventBubble/index.js'
export default function Length(

@@ -16,3 +14,3 @@ $trap, $trapPropertyName, $aliases

$eventTarget.addEventListener(
'lengthSet', DynamicEventBubble
'lengthSet', DETEventBubble
)

@@ -25,3 +23,3 @@ return Object.defineProperty(

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'lengthSet',

@@ -28,0 +26,0 @@ {

@@ -1,5 +0,3 @@

import {
DynamicEvent,
DynamicEventBubble,
} from '../../../Events/index.js'
import DETEvent from '../../../../../DynamicEvent/index.js'
import DETEventBubble from '../../../../../DynamicEvent/DynamicEventBubble/index.js'
export default function Pop(

@@ -16,3 +14,3 @@ $trap, $trapPropertyName, $aliases

$eventTarget.addEventListener(
'lengthSet', DynamicEventBubble
'lengthSet', DETEventBubble
)

@@ -31,3 +29,3 @@ return Object.defineProperty(

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'lengthSet',

@@ -34,0 +32,0 @@ {

import { isDirectInstanceOf } from '../../Coutil/index.js'
import DynamicEventTarget from '../../../../../index.js'
import {
DynamicEvent,
DynamicEventBubble,
} from '../../../Events/index.js'
import DETEvent from '../../../../../DynamicEvent/index.js'
import DETEventBubble from '../../../../../DynamicEvent/DynamicEventBubble/index.js'
export default function Push(

@@ -18,6 +16,6 @@ $trap, $trapPropertyName, $aliases

$eventTarget.addEventListener(
'push', DynamicEventBubble
'push', DETEventBubble
)
$eventTarget.addEventListener(
'pushProp', DynamicEventBubble
'pushProp', DETEventBubble
)

@@ -47,3 +45,3 @@ return Object.defineProperty(

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'pushProp',

@@ -64,3 +62,3 @@ {

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'push',

@@ -67,0 +65,0 @@ {

@@ -1,5 +0,3 @@

import {
DynamicEvent,
DynamicEventBubble,
} from '../../../Events/index.js'
import DETEvent from '../../../../../DynamicEvent/index.js'
import DETEventBubble from '../../../../../DynamicEvent/DynamicEventBubble/index.js'
export default function Reverse(

@@ -16,3 +14,3 @@ $trap, $trapPropertyName, $aliases

$eventTarget.addEventListener(
'reverse', DynamicEventBubble
'reverse', DETEventBubble
)

@@ -24,3 +22,3 @@ return Object.defineProperty(

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'reverse',

@@ -27,0 +25,0 @@ {

@@ -1,5 +0,3 @@

import {
DynamicEvent,
DynamicEventBubble,
} from '../../../Events/index.js'
import DETEvent from '../../../../../DynamicEvent/index.js'
import DETEventBubble from '../../../../../DynamicEvent/DynamicEventBubble/index.js'
export default function Shift(

@@ -16,3 +14,3 @@ $trap, $trapPropertyName, $aliases

$eventTarget.addEventListener(
'shift', DynamicEventBubble
'shift', DETEventBubble
)

@@ -31,3 +29,3 @@ return Object.defineProperty(

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'shift',

@@ -34,0 +32,0 @@ {

@@ -1,5 +0,3 @@

import {
DynamicEvent,
DynamicEventBubble,
} from '../../../Events/index.js'
import DETEvent from '../../../../../DynamicEvent/index.js'
import DETEventBubble from '../../../../../DynamicEvent/DynamicEventBubble/index.js'
export default function Splice(

@@ -16,9 +14,9 @@ $trap, $trapPropertyName, $aliases

$eventTarget.addEventListener(
'spliceDelete', DynamicEventBubble
'spliceDelete', DETEventBubble
)
$eventTarget.addEventListener(
'spliceAdd', DynamicEventBubble
'spliceAdd', DETEventBubble
)
$eventTarget.addEventListener(
'splice', DynamicEventBubble
'splice', DETEventBubble
)

@@ -56,3 +54,3 @@ return Object.defineProperty(

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'spliceDelete',

@@ -86,3 +84,3 @@ {

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'spliceAdd',

@@ -104,3 +102,3 @@ {

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'splice',

@@ -107,0 +105,0 @@ {

import { isDirectInstanceOf } from '../../Coutil/index.js'
import DynamicEventTarget from '../../../../../index.js'
import {
DynamicEvent,
DynamicEventBubble,
} from '../../../Events/index.js'
import DETEvent from '../../../../../DynamicEvent/index.js'
import DETEventBubble from '../../../../../DynamicEvent/DynamicEventBubble/index.js'
export default function Unshift(

@@ -22,3 +20,3 @@ $trap, $trapPropertyName, $aliases

$eventTarget.addEventListener(
'unshiftProp', DynamicEventBubble
'unshiftProp', DETEventBubble
)

@@ -53,3 +51,3 @@ return Object.defineProperty(

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'unshiftProp',

@@ -75,3 +73,3 @@ {

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'unshift',

@@ -78,0 +76,0 @@ {

@@ -1,5 +0,3 @@

import {
DynamicEvent,
DynamicEventBubble,
} from '../../../Events/index.js'
import DETEvent from '../../../../../DynamicEvent/index.js'
import DETEventBubble from '../../../../../DynamicEvent/DynamicEventBubble/index.js'
export default function Clear(

@@ -16,3 +14,3 @@ $trap, $trapPropertyName, $aliases

$eventTarget.addEventListener(
'clear', DynamicEventBubble
'clear', DETEventBubble
)

@@ -19,0 +17,0 @@ return Object.defineProperty(

@@ -1,5 +0,3 @@

import {
DynamicEvent,
DynamicEventBubble,
} from '../../../Events/index.js'
import DETEvent from '../../../../../DynamicEvent/index.js'
import DETEventBubble from '../../../../../DynamicEvent/DynamicEventBubble/index.js'
export default function Delete(

@@ -16,6 +14,6 @@ $trap, $trapPropertyName, $aliases

$eventTarget.addEventListener(
'delete', DynamicEventBubble
'delete', DETEventBubble
)
$eventTarget.addEventListener(
'deleteKey', DynamicEventBubble
'deleteKey', DETEventBubble
)

@@ -27,3 +25,3 @@ return Object.defineProperty(

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'delete',

@@ -40,3 +38,3 @@ {

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'deleteKey',

@@ -43,0 +41,0 @@ {

@@ -1,5 +0,3 @@

import {
DynamicEvent,
DynamicEventBubble,
} from '../../../Events/index.js'
import DETEvent from '../../../../../DynamicEvent/index.js'
import DETEventBubble from '../../../../../DynamicEvent/DynamicEventBubble/index.js'
export default function Set(

@@ -20,3 +18,3 @@ $trap, $trapPropertyName, $aliases

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'set',

@@ -34,3 +32,3 @@ {

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'setKey',

@@ -37,0 +35,0 @@ {

import { isDirectInstanceOf } from '../../Coutil/index.js'
import DynamicEventTarget from '../../../../../index.js'
import {
DynamicEvent,
DynamicEventBubble,
} from '../../../Events/index.js'
import DETEvent from '../../../../../DynamicEvent/index.js'
import DETEventBubble from '../../../../../DynamicEvent/DynamicEventBubble/index.js'
export default function Assign(

@@ -60,9 +58,9 @@ $trap, $trapPropertyName, $aliases, $options

detObject.addEventListener(
'assignSourceProperty', DynamicEventBubble
'assignSourceProperty', DETEventBubble
)
detObject.addEventListener(
'assignSource', DynamicEventBubble
'assignSource', DETEventBubble
)
detObject.addEventListener(
'assign', DynamicEventBubble
'assign', DETEventBubble
)

@@ -82,3 +80,3 @@ Object.assign($root, {

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'assignSourceProperty',

@@ -99,3 +97,3 @@ {

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'assignSource',

@@ -114,3 +112,3 @@ {

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'assign',

@@ -117,0 +115,0 @@ {

@@ -6,6 +6,4 @@ import {

import DynamicEventTarget from '../../../../../index.js'
import {
DynamicEvent,
DynamicEventBubble,
} from '../../../Events/index.js'
import DETEvent from '../../../../../DynamicEvent/index.js'
import DETEventBubble from '../../../../../DynamicEvent/DynamicEventBubble/index.js'
export default function DefineProperties(

@@ -23,3 +21,3 @@ $trap, $trapPropertyName, $aliases, $options

$eventTarget.addEventListener(
'defineProperties', DynamicEventBubble
'defineProperties', DETEventBubble
)

@@ -40,3 +38,3 @@ return Object.defineProperty(

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'defineProperties',

@@ -43,0 +41,0 @@ {

@@ -6,6 +6,4 @@ import {

import DynamicEventTarget from '../../../../../index.js'
import {
DynamicEvent,
DynamicEventBubble,
} from '../../../Events/index.js'
import DETEvent from '../../../../../DynamicEvent/index.js'
import DETEventBubble from '../../../../../DynamicEvent/DynamicEventBubble/index.js'
export default function DefineProperty(

@@ -41,6 +39,6 @@ $trap, $trapPropertyName, $aliases, $options

$root[propertyKey].removeEventListener(
'defineProperty', DynamicEventBubble
'defineProperty', DETEventBubble
)
$root[propertyKey].addEventListener(
'defineProperty', DynamicEventBubble
'defineProperty', DETEventBubble
)

@@ -113,3 +111,3 @@ // Root Define Properties, Descriptor Tree

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'defineProperty',

@@ -116,0 +114,0 @@ {

@@ -6,6 +6,4 @@ import {

import DynamicEventTarget from '../../../../../index.js'
import {
DynamicEvent,
DynamicEventBubble,
} from '../../../Events/index.js'
import DETEvent from '../../../../../DynamicEvent/index.js'
import DETEventBubble from '../../../../../DynamicEvent/DynamicEventBubble/index.js'
export default function Freeze(

@@ -34,3 +32,3 @@ $trap, $trapPropertyName, $aliases, $options

$propertyValue.addEventListener(
'freeze', DynamicEventBubble
'freeze', DETEventBubble
)

@@ -47,3 +45,3 @@ $propertyValue.freeze()

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'freeze',

@@ -50,0 +48,0 @@ {

@@ -6,6 +6,4 @@ import {

import DynamicEventTarget from '../../../../../index.js'
import {
DynamicEvent,
DynamicEventBubble,
} from '../../../Events/index.js'
import DETEvent from '../../../../../DynamicEvent/index.js'
import DETEventBubble from '../../../../../DynamicEvent/DynamicEventBubble/index.js'
export default function Seal(

@@ -34,3 +32,3 @@ $trap, $trapPropertyName, $aliases, $options

$propertyValue.addEventListener(
'seal', DynamicEventBubble
'seal', DETEventBubble
)

@@ -47,3 +45,3 @@ $propertyValue.seal()

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'seal',

@@ -50,0 +48,0 @@ {

@@ -5,6 +5,4 @@ import {

} from '../../Coutil/index.js'
import {
DynamicEvent,
DynamicEventBubble,
} from '../../../Events/index.js'
import DETEvent from '../../../../../DynamicEvent/index.js'
import DETEventBubble from '../../../../../DynamicEvent/DynamicEventBubble/index.js'
export default function SetPrototypeOf(

@@ -21,3 +19,3 @@ $trap, $trapPropertyName, $aliases

$eventTarget.addEventListener(
'setPrototypeOf', DynamicEventBubble
'setPrototypeOf', DETEventBubble
)

@@ -30,3 +28,3 @@ return Object.defineProperty(

$eventTarget.dispatchEvent(
new DynamicEvent(
new DETEvent(
'setPrototypeOf',

@@ -33,0 +31,0 @@ {

@@ -10,2 +10,3 @@ import { typeOf } from '../../Coutil/index.js'

objectSealRecurse: true,
objectSetMerge: true,
})

@@ -91,2 +92,3 @@ export default class DynamicEventTarget extends EventTarget {

this.#_proxy = new Proxy(this.#root, this.#handler)
this.#handler.proxy = this.#proxy
if(this.type === 'object') {

@@ -116,2 +118,3 @@ this.#_proxy.assign(this.#root)

objectSealRecurse,
objectSetMerge,
} = this.#options

@@ -138,2 +141,5 @@ this.#_handler = new Handler(this.#aliases, {

},
set: {
merge: objectSetMerge
},
}

@@ -158,3 +164,5 @@ }

}
parse() {
parse($settings = {
type: 'object', // 'string',
}) {
let parsement = (

@@ -182,7 +190,15 @@ this.type === 'object'

}
return parsement
if(
$settings.type === 'object' ||
$settings.type === 'Object'
) {
return parsement
} else if(
$settings.type === 'json' ||
$settings.type === 'JSON'
) {
return JSON.stringify(parsement, null, 2)
}
return undefined
}
inspect() {
return JSON.stringify(this.parse(), null, 2)
}
}
# Dynamic Event Target (DET) Object
- [Overview](#overview)
- [Importation](#importation)
- [Instantiation](#instantiation)
- [Parsement](#parsement)
- [Parse Object](#parse-object)
- [Parse JSON](#parse-json)
- [DET Object Event Listener Signment](#det-object-event-listener-signment)
- [Add Event Listener - Base Object](#add-event-listener---base-object)
- [Assign Base-Referenced Object Property](#assign-base-referenced-object-property)
- [Assign Base-Referenced Subbase Object Property](#assign-base-referenced-subbase-object-property)
- [Add Event Listener - Subbase Object](#add-event-listener---subbase-object)
- [Assign subbase object property](#assign-subbase-referenced-object-property)
- [Assign Subbase-Referenced Subbbase Object Property](#assign-subbase-referenced-subbbase-object-property)
- [Remove Event Lister](#remove-event-listener)
- [Remove Base-Referenced Event Listener](#remove-base-referenced-event-listener)
- [Remove Subbased-Referenced Event Listener](#remove-subbased-referenced-event-listener)
- [DET Object Ventilation](#det-object-ventilation)
- [1. DET Object Assign Events](#1-det-object-assign-events)
- [1.1. "assignSourceProperty Event"](#11-assignsourceproperty-event)
- [1.2. "assignSource" Event](#12-assignsource-event)
- [1.3. "assign" Event](#13-assign-event)
- [2. DET Object Define Properties Events](#2-det-object-define-properties-events)
- [2.1. "defineProperties" Event](#21-defineproperties-event)
- [3. DET Object Define Property Events](#3-det-object-define-property-event)
- [3.1. "defineProperty" Event](#31-defineproperty-event)
- [4. DET Object Freeze Event](#4-det-object-freeze-event)
- [4.1. "freeze" Event](#41-freeze)
- [5. Object Seal](#5-object-seal)
- [5.1. "seal" Event](#51-seal)
- [Object Set Prototype](#6-object-set-prototype)
- ["setPrototypeOf" Event](#61-setprototypeof)
## Overview
Dynamic Event Target (DET) ventilates **Object Property Modifier Functions**:

@@ -39,7 +71,7 @@ - **6** Object Property Modifier Functions

## Parsement
### Parse
### Parse Object
```
object.parse()
```
**Returns Plain Object**
*Returns Plain JS Object*
```

@@ -58,8 +90,9 @@ {

```
## Inspection
### Inspect
### Parse JSON
```
object.inspect()
object.parse({
type: "JSON"
})
```
**Returns JSON Object**
*Returns JSON String*
```

@@ -78,67 +111,134 @@ {

```
## DET Object Property Signment
## DET Object Event Listener Signment
### Add Event Listener - Base Object
For demonstration purposes, a simple event logger:
```
function objectAssign($event) {
function DETEventLog($event) {
console.log(
'\n', $event.basename, $event.path,
'\n', $event.type, $event.detail
'\n', 'basename', $event.basename,
'\n', 'path', $event.path,
'\n', 'type', $event.type,
'\n', 'detail', JSON.stringify(
$event.detail, null, 2
)
)
}
object.addEventListener("assign", objectAssign)
```
### Add Event Listener - Base Object
```
object.addEventListener('assign', DETEventLog)
```
#### Assign Base-Referenced Object Property
```
object.assign({
aaa: 111111
})
```
##### Emits DynamicEvent
```
basename null
path null
type assign
detail {
"sources": [
{
"aaa": 111111
}
]
}
```
#### Assign Base-Referenced Subbase Object Property
```
object.assign({
ccc: {
fff: {
ggg: 777777,
hhh: {
iii: 999
}
}
ddd: 444444
}
})
```
**Emits DynamicEvent**
##### Emits DynamicEvents
###### Event Log #1
```
object.assign({
ccc: {
fff: {
ggg: 777777,
hhh: {
iii: 999
basename ccc
path ccc
type assign
detail {
"sources": [
{
"ddd": 444444
}
]
}
```
###### Event Log #2
```
basename null
path null
type assign
detail {
"sources": [
{
"ccc": {
"ddd": 444444
}
}
}
]
}
```
### Add Event Listener - Subbase Object
```
object.ccc.addEventListener("assign", DETEventLog)
```
#### Assign Subbase-Referenced Object Property
```
object.ccc.assign({
ddd: 444444444
})
```
##### Emits DynamicEvent
```
basename ccc
path ccc
type assign
detail {
"sources": [
{
"ddd": 444444444
}
]
}
```
#### Assign Subbase-Referenced Subbbase Object Property
```
object.ccc.fff.assign({
ggg: 777777
})
```
##### Emits DynamicEvent
```
basename fff
path ccc.fff
type assign
detail {
"sources": [
{
"ggg": 777777
}
]
}
```
### Remove Event Listener
#### Remove Base-Referenced Event Listener
```
object.removeEventListener("assign", objectAssign)
object.removeEventListener("assign", DETEventLog)
object.assign({ aaa: 111111111 })
/*
Log: empty
*/
```
### Bubble Event Listener
##### Emits Nothing
#### Remove Subbased-Referenced Event Listener
```
function objectAssign($event) {
console.log(
$event.path, $event.basename,
$event.type, $event.detail
)
}
object.addEventListener("assign", objectAssign)
object.assign({
aaa: {
ddd: {
hhh: {
iii: 999999
}
}
}
object.ccc.removeEventListener("assign", DETEventLog)
object.ccc.assign({
ddd: 444444444
})
/*
Log: assign { target: DynamicEventTarget }
*/
```
##### Emits Nothing
## DET Object Ventilation

@@ -148,2 +248,3 @@ ### 1. DET Object Assign Events

`assignSourceProperty` event occurs after each source property assignment to DET instance.
##### Event Detail
```

@@ -161,4 +262,11 @@ {

|source|Object|Assigned Source|
##### Subbase-Referenced Property Assignment
```
object.ccc.assign({
eee: 555
})
```
#### 1.2. "assignSource" Event
`assignSource` event occurs after each source assignment to DET instance.
`assignSource` event occurs after each source assignment to DET instance.
##### Event Detail
```

@@ -173,3 +281,4 @@ {

#### 1.3. "assign" Event
`assign` event occurs after all sources assigned to DET instance.
`assign` event occurs after all sources assigned to DET instance.
##### Event Detail
```

@@ -186,3 +295,4 @@ {

#### 2.1. "defineProperties" Event
`defineProperties` event occurs after all properties defined on DET instance.
`defineProperties` event occurs after all properties defined on DET instance.
##### Event Detail
```

@@ -199,2 +309,3 @@ {

`defineProperty` event occurs after each property definition on DET instance.
##### Event Detail
```

@@ -214,2 +325,3 @@ {

`freeze` event occurs after DET instance frozen.
##### Event Detail
```

@@ -226,2 +338,3 @@ {

`seal` event occurs after DET instance sealed.
##### Event Detail
```

@@ -238,2 +351,3 @@ {

`setPrototypeOf` event occurs after DET instance prototype is set.
##### Event Detail
```

@@ -240,0 +354,0 @@ {

{
"name": "js-mvc-framework",
"author": "Thomas Patrick Welborn",
"version": "1.0.16",
"version": "1.0.17",
"type": "module",

@@ -6,0 +6,0 @@ "main": "./development/index.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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