Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Strict mode.
'use strict'
// Package modules.
const sharp = require('sharp')
const sinon = require('sinon')
// Configure.
const methods = Object.getOwnPropertyNames(sharp.prototype)
// Patch methods, add reset and restore handlers.
methods.forEach((name) => sinon.spy(sharp.prototype, name))
sharp.prototype.reset = () => {
methods.forEach((name) => sharp.prototype[name].resetHistory())
}
sharp.prototype.restore = () => {
methods.forEach((name) => sharp.prototype[name].restore())
}
// Exports.
module.exports = sharp
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// Strict mode.
'use strict'
// Package modules.
const sharp = require('sharp')
const sinon = require('sinon')
// Configure.
const methods = Object.getOwnPropertyNames(sharp.prototype)
// Patch methods, add reset and restore handlers.
methods.forEach((name) => sinon.spy(sharp.prototype, name))
sharp.prototype.reset = () => {
methods.forEach((name) => sharp.prototype[name].resetHistory())
}
sharp.prototype.restore = () => {
methods.forEach((name) => sharp.prototype[name].restore())
}
// Exports.
module.exports = sharp
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// Strict mode.
'use strict'
// Package modules.
const sharp = require('sharp')
const sinon = require('sinon')
// Configure.
const methods = Object.getOwnPropertyNames(sharp.prototype)
// Patch methods, add reset and restore handlers.
methods.forEach((name) => sinon.spy(sharp.prototype, name))
sharp.prototype.reset = () => {
methods.forEach((name) => sharp.prototype[name].resetHistory())
}
sharp.prototype.restore = () => {
methods.forEach((name) => sharp.prototype[name].restore())
}
// Exports.
module.exports = sharp
import { registerBridge } from "../"
import { ivm } from "../../"
import { transferInto } from "../../utils/buffer"
import log from "../../log"
import * as sharp from "sharp"
import { Bridge } from "../bridge"
import { Runtime } from "../../runtime"
type imageOperation = (...args: any[]) => sharp.Sharp
const allowedOperations: Map = new Map([
["resize", sharp.prototype.resize],
["scale", scale],
["crop", crop],
["embed", sharp.prototype.embed],
["background", sharp.prototype.background],
["withoutEnlargement", sharp.prototype.withoutEnlargement],
["withMetadata", sharp.prototype.withMetadata],
["overlayWith", sharp.prototype.overlayWith],
["negate", sharp.prototype.negate],
["max", sharp.prototype.max],
["extend", sharp.prototype.extend],
["flatten", sharp.prototype.flatten],
// output
["png", sharp.prototype.png],
["webp", sharp.prototype.webp],
import * as sharp from "sharp"
import { Bridge } from "../bridge"
import { Runtime } from "../../runtime"
type imageOperation = (...args: any[]) => sharp.Sharp
const allowedOperations: Map = new Map([
["resize", sharp.prototype.resize],
["scale", scale],
["crop", crop],
["embed", sharp.prototype.embed],
["background", sharp.prototype.background],
["withoutEnlargement", sharp.prototype.withoutEnlargement],
["withMetadata", sharp.prototype.withMetadata],
["overlayWith", sharp.prototype.overlayWith],
["negate", sharp.prototype.negate],
["max", sharp.prototype.max],
["extend", sharp.prototype.extend],
["flatten", sharp.prototype.flatten],
// output
["png", sharp.prototype.png],
["webp", sharp.prototype.webp],
["jpeg", sharp.prototype.jpeg]
])
const metadataFields = [
"format",
"width",
"height",
"number",
methods.forEach((name) => sharp.prototype[name].resetHistory())
}