Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F72030218
RawSource.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jul 14, 08:07
Size
1 KB
Mime Type
text/x-c++
Expires
Tue, Jul 16, 08:07 (2 d)
Engine
blob
Format
Raw Data
Handle
19024380
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
RawSource.js
View Options
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict"
;
const
Source
=
require
(
"./Source"
);
const
{
SourceNode
}
=
require
(
"source-map"
);
const
{
SourceListMap
}
=
require
(
"source-list-map"
);
class
RawSource
extends
Source
{
constructor
(
value
,
convertToString
=
false
)
{
super
();
const
isBuffer
=
Buffer
.
isBuffer
(
value
);
if
(
!
isBuffer
&&
typeof
value
!==
"string"
)
{
throw
new
TypeError
(
"argument 'value' must be either string of Buffer"
);
}
this
.
_valueIsBuffer
=
!
convertToString
&&
isBuffer
;
this
.
_value
=
convertToString
&&
isBuffer
?
undefined
:
value
;
this
.
_valueAsBuffer
=
isBuffer
?
value
:
undefined
;
}
isBuffer
()
{
return
this
.
_valueIsBuffer
;
}
source
()
{
if
(
this
.
_value
===
undefined
)
{
this
.
_value
=
this
.
_valueAsBuffer
.
toString
(
"utf-8"
);
}
return
this
.
_value
;
}
buffer
()
{
if
(
this
.
_valueAsBuffer
===
undefined
)
{
this
.
_valueAsBuffer
=
Buffer
.
from
(
this
.
_value
,
"utf-8"
);
}
return
this
.
_valueAsBuffer
;
}
map
(
options
)
{
return
null
;
}
node
(
options
)
{
if
(
this
.
_value
===
undefined
)
{
this
.
_value
=
this
.
_valueAsBuffer
.
toString
(
"utf-8"
);
}
return
new
SourceNode
(
null
,
null
,
null
,
this
.
_value
);
}
listMap
(
options
)
{
if
(
this
.
_value
===
undefined
)
{
this
.
_value
=
this
.
_valueAsBuffer
.
toString
(
"utf-8"
);
}
return
new
SourceListMap
(
this
.
_value
);
}
updateHash
(
hash
)
{
if
(
this
.
_valueAsBuffer
===
undefined
)
{
this
.
_valueAsBuffer
=
Buffer
.
from
(
this
.
_value
,
"utf-8"
);
}
hash
.
update
(
"RawSource"
);
hash
.
update
(
this
.
_valueAsBuffer
);
}
}
module
.
exports
=
RawSource
;
Event Timeline
Log In to Comment