Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
promised-value
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
tools
promised-value
Commits
01cab452
Commit
01cab452
authored
Aug 31, 2018
by
Vadym Gidulian
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1-fix-descriptors' into 'master'
Resolve "Fix property descriptors" Closes
#1
See merge request
!1
parents
1900d971
45b38912
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
index.js
src/index.js
+4
-0
test.js
test/test.js
+22
-0
No files found.
src/index.js
View file @
01cab452
...
@@ -17,11 +17,14 @@ function PromisedValue(initialValue) {
...
@@ -17,11 +17,14 @@ function PromisedValue(initialValue) {
Object
.
defineProperties
(
this
,
{
Object
.
defineProperties
(
this
,
{
isReady
:
{
isReady
:
{
enumerable
:
true
,
get
()
{
get
()
{
return
initialized
;
return
initialized
;
}
}
},
},
value
:
{
value
:
{
configurable
:
true
,
enumerable
:
true
,
get
()
{
get
()
{
return
value
;
return
value
;
},
},
...
@@ -37,6 +40,7 @@ function PromisedValue(initialValue) {
...
@@ -37,6 +40,7 @@ function PromisedValue(initialValue) {
}
}
},
},
willBeReady
:
{
willBeReady
:
{
enumerable
:
true
,
get
()
{
get
()
{
return
willBeReady
;
return
willBeReady
;
}
}
...
...
test/test.js
View file @
01cab452
...
@@ -32,3 +32,25 @@ test('Use new only', t => {
...
@@ -32,3 +32,25 @@ test('Use new only', t => {
t
.
pass
();
t
.
pass
();
}
}
});
});
test
(
'Property descriptors'
,
t
=>
{
const
v
=
new
PV
(
42
);
t
.
true
(
Object
.
keys
(
v
).
toString
()
===
[
'isReady'
,
'value'
,
'willBeReady'
].
toString
());
Object
.
defineProperty
(
v
,
'value'
,
{
value
:
42
,
writable
:
false
});
t
.
is
(
v
.
value
,
42
);
try
{
v
.
value
=
43
;
t
.
fail
(
'An exception should be thrown'
);
}
catch
(
e
)
{
t
.
pass
();
}
delete
v
.
value
;
t
.
false
(
v
.
hasOwnProperty
(
'value'
));
t
.
true
(
Object
.
keys
(
v
).
toString
()
===
[
'isReady'
,
'willBeReady'
].
toString
());
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment