New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mock-gcs

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mock-gcs - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

9

lib/MockFile.d.ts
/// <reference types="node" />
/// <reference types="node" />
import { CreateReadStreamOptions, CreateWriteStreamOptions, DownloadOptions, DownloadResponse, FileOptions, GetSignedUrlConfig, GetSignedUrlResponse, SaveOptions } from '@google-cloud/storage';
import { CreateReadStreamOptions, CreateWriteStreamOptions, DownloadOptions, DownloadResponse, FileOptions, GetSignedUrlConfig, GetSignedUrlResponse, SaveOptions, CopyOptions, CopyResponse } from '@google-cloud/storage';
import MockBucket, { IBucket } from './MockBucket';

@@ -67,3 +67,10 @@ import { Readable, Writable } from 'stream';

save(data: string | Buffer, options?: SaveOptions): Promise<void>;
/**
* Copies the current file to the specified destination.
* @param destination The destination can be a string (file name), Bucket, or File object.
* @param options Optional CopyOptions.
* @returns A promise that resolves to the CopyResponse.
*/
copy(destination: string | MockBucket | MockFile, options?: CopyOptions): Promise<CopyResponse>;
}
export default MockFile;

@@ -224,2 +224,45 @@ "use strict";

};
/**
* Copies the current file to the specified destination.
* @param destination The destination can be a string (file name), Bucket, or File object.
* @param options Optional CopyOptions.
* @returns A promise that resolves to the CopyResponse.
*/
MockFile.prototype.copy = function (destination, options) {
return __awaiter(this, void 0, void 0, function () {
var targetBucket, targetFileName, contents, metadata, newMetadata, newFile;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (typeof destination === 'string') {
targetBucket = this.bucket;
targetFileName = destination;
}
else if ('name' in destination && 'file' in destination) {
targetBucket = destination;
targetFileName = this.name;
}
else if ('name' in destination) {
targetBucket = destination.bucket;
targetFileName = destination.name;
}
else {
throw new Error('Invalid destination type');
}
return [4 /*yield*/, this.download()];
case 1:
contents = (_a.sent())[0];
return [4 /*yield*/, this.getMetadata()];
case 2:
metadata = (_a.sent())[0];
newMetadata = __assign(__assign({}, metadata), options === null || options === void 0 ? void 0 : options.metadata);
newFile = targetBucket.file(targetFileName);
return [4 /*yield*/, newFile.save(contents, { metadata: newMetadata })];
case 3:
_a.sent();
return [2 /*return*/, [newFile, newMetadata]];
}
});
});
};
return MockFile;

@@ -226,0 +269,0 @@ }());

2

package.json
{
"name": "mock-gcs",
"version": "1.1.0",
"version": "1.2.0",
"description": "Mock implementation of the Google Cloud Storage SDK.",

@@ -5,0 +5,0 @@ "url": "https://github.com/aldipermanaetikaputra/mock-gcs",

@@ -15,2 +15,3 @@ # mock-gcs

- `bucket.cloudStorageURI`
- `file.copy()` (promise-based only)
- `file.delete()` (promise-based only)

@@ -17,0 +18,0 @@ - `file.exists()` (promise-based only)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc