This repository has been archived by the owner on Oct 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathtest-stream-layers.js
67 lines (48 loc) · 1.61 KB
/
test-stream-layers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
var t = require('tap')
var photoshop = require('../')
// require('../lib/functionToExtendScript').DEBUG = true
// require('../lib/transformES6').DEBUG = true
// require('../lib/extendscript-stream').debug = true
t.test("stream layers", function(t){
var readStream = photoshop.createStream(function(writeStream, psd){
function $time(event){
if ($time.event) writeStream.writeln(JSON.stringify({key:'duration', event:$time.event, duration:$.hiresTimer/1000}))
else $.hiresTimer // reset to 0
$time.event = event
}
$time('open')
app.open(File(psd))
$time('getLayerIds')
PSFakeDOM.getLayerIds().forEach(function(id){
$time('getMetaDataForLayerId')
writeStream.write(
JSON.stringify({ key:'meta', id:id, value:
PSFakeDOM.getMetaDataForLayerId(
id)}))
$time('getParsedMetaDataForLayerId')
writeStream.write(
JSON.stringify({ key:'parsed', id:id, value:
PSFakeDOM.getParsedMetaDataForLayerId(
id)}))
$time('layer')
writeStream.write(
JSON.stringify({ key:'layer', id:id, value:
PSFakeDOM.executeActionGet(
PSFakeDOM.layerRefForId(
id))}))
})
$time('close')
app.activeDocument.close()
$time()
}, [__dirname + '/stuff/some stuff.psd'])
readStream
.pipe(require('JSONStream').parse())
.on('data', function(object){
t.ok('key' in object)
console.dir(object)
})
// .pipe(process.stdout)
readStream.on('end', function(){
t.end()
})
})