Created
July 14, 2021 22:29
-
-
Save vgorloff/597d840f1b2a915b88b36c342cf56576 to your computer and use it in GitHub Desktop.
so.SwiftDeflate+NodeJSInflateRaw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let data = "HelloZip!".data(using: .utf8)! | |
let compressedData = (data as NSData).compressed(using: .zlib) as Data | |
let compressedDataAsBase64EncodedString = compressedData.base64EncodedString() | |
print(compressedDataAsBase64EncodedString) | |
// Prints: 80jNycmPyixQBAA= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zlib from "zlib"; | |
const compressedDataAsBase64EncodedString = "80jNycmPyixQBAA=" | |
const compressedData = Buffer.from(compressedDataAsBase64EncodedString, "base64") | |
const data = zlib.inflateRawSync(compressedData) | |
console.log(data.toString()) | |
// Prints: HelloZip! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment