Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

q-io

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

q-io - npm Package Compare versions

Comparing version 1.6.2 to 1.6.3

spec/fs/mock/append-spec.js

33

fs-common.js

@@ -22,4 +22,8 @@

/**
* @param {String} path
* @param {Object} options
* Read a complete file.
* @param {String} path Path to the file.
* @param {Object} [options] An object with options.
* @param {String} [options.flags] The mode to open the file with.
* @param {String} [options.charset] The charset to open the file with.
* second argument.
* @returns {Promise * (String || Buffer)}

@@ -33,3 +37,3 @@ */

options.flags = flags;
options.carset = charset;
options.charset = charset;
}

@@ -49,5 +53,8 @@ options.flags = "r" + (options.flags || "").replace(/r/g, "");

/**
* @param {String} path
* Write content to a file, overwriting the existing content.
* @param {String} path Path to the file.
* @param {String || Buffer} content
* @param {Object} options
* @param {Object} [options] An object with options.
* @param {String} [options.flags] The mode to open the file with.
* @param {String} [options.charset] The charset to open the file with.
* @returns {Promise * Undefined} a promise that resolves

@@ -63,5 +70,5 @@ * when the writing is complete.

options.flags = flags;
options.carset = charset;
options.charset = charset;
}
flags = "w" + (flags || "").replace(/[wb]/g, "");
flags = "w" + (options.flags || "").replace(/[wb]/g, "");
if (content instanceof Buffer) {

@@ -78,2 +85,12 @@ flags += "b";

/**
* Append content to the end of a file.
* @param {String} path Path to the file.
* @param {String || Buffer} content
* @param {Object} [options] An object with options.
* @param {String} [options.flags] The mode to open the file with.
* @param {String} [options.charset] The charset to open the file with.
* @returns {Promise * Undefined} a promise that resolves
* when the writing is complete.
*/
exports.append = function (path, content, flags, charset, options) {

@@ -86,3 +103,3 @@ var self = this;

options.flags = flags;
options.carset = charset;
options.charset = charset;
}

@@ -89,0 +106,0 @@ flags = "w+" + (options.flags || "").replace(/[w\+]/g, "");

{
"name": "q-io",
"version": "1.6.2",
"version": "1.6.3",
"description": "IO using Q promises",

@@ -5,0 +5,0 @@ "homepage": "http://github.com/kriskowal/q-io/",

@@ -6,2 +6,3 @@ "use strict";

var FS = require("../../../fs");
/*global describe,it,expect */

@@ -23,3 +24,19 @@ describe("read", function () {

});
it("calls open correctly", function () {
return FS.mock(FS.join(__dirname, "fixture"))
.then(function (mock) {
mock.open = function (path, options) {
expect(path).toBe("hello.txt");
expect(options.flags).toBe("ra");
expect(options.charset).toBe("utf8");
return Q.resolve({read: function () {}, close: function () {}});
};
return mock.read("hello.txt", "a", "utf8");
});
});
});

@@ -6,6 +6,6 @@ "use strict";

var FS = require("../../../fs");
/*global describe,it,expect */
describe("write", function () {
it("should write a file to a mock filesystem", function () {
return FS.mock(FS.join(__dirname, "fixture"))

@@ -22,7 +22,50 @@ .then(function (mock) {

expect(isFile).toBe(true);
});
});
});
it("takes a flags argument", function () {
return FS.mock(FS.join(__dirname, "fixture"))
.then(function (mock) {
return Q.fcall(function () {
return mock.write("hello.txt", "Goodbye!\n", "a");
})
.then(function () {
return mock.read("hello.txt");
})
.then(function (contents) {
expect(contents).toBe("Hello, World!\nGoodbye!\n");
});
});
});
it("takes an options object with flags", function () {
return FS.mock(FS.join(__dirname, "fixture"))
.then(function (mock) {
return Q.fcall(function () {
return mock.write("hello.txt", "Goodbye!\n", { flags: "a" });
})
.then(function () {
return mock.read("hello.txt");
})
.then(function (contents) {
expect(contents).toBe("Hello, World!\nGoodbye!\n");
});
});
});
it("calls open correctly", function () {
return FS.mock(FS.join(__dirname, "fixture"))
.then(function (mock) {
mock.open = function (path, options) {
expect(path).toBe("hello.txt");
expect(options.flags).toBe("wa");
expect(options.charset).toBe("utf8");
return Q.resolve({write: function () {}, close: function () {}});
};
return mock.write("hello.txt", "Goodbye!\n", "a", "utf8");
});
});
});
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