Skip to content

Commit c11eba9

Browse files
committed
docs(migration): add initial migration instructions
1 parent bb5835b commit c11eba9

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

MIGRATION.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Migration
2+
3+
## Migrating from v0 to v1
4+
5+
Most important notes:
6+
7+
* The API is now async
8+
* The new plugin based system requires a different configuration
9+
* The result is now as a Buffer available as `result.content`
10+
* All other metadata is now available within `result.metadata`
11+
12+
13+
**old API**:
14+
```js
15+
;(async () => {
16+
const absolutePath = '/foo/bar/baz.jpg'
17+
18+
const result = await new Promise((resolve, reject) => {
19+
try {
20+
const result = sqip({
21+
filename: absolutePath,
22+
// other options
23+
})
24+
resolve(result)
25+
} catch (error) {
26+
reject(error)
27+
}
28+
})
29+
30+
// Content
31+
console.log(result.final_svg)
32+
33+
// Metadata
34+
console.log(result.width)
35+
console.log(result.height)
36+
console.log(result.type)
37+
})()
38+
```
39+
40+
**new API**:
41+
```js
42+
;(async () => {
43+
const absolutePath = '/foo/bar/baz.jpg'
44+
45+
const result = await sqip({
46+
input: absolutePath,
47+
// other options like output or plugin config
48+
})
49+
50+
// Content (as buffer!)
51+
console.log(result.content)
52+
53+
// Metadata
54+
console.log(result.metadata)
55+
})()
56+
```

0 commit comments

Comments
 (0)