mobiletto 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +4 -0
  2. package/index.js +5 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -71,6 +71,10 @@ Today the supported drivers are:
71
71
  local.write(path, generator)
72
72
  s3.write(path, generator)
73
73
 
74
+ // Write an entire file at once (convenience method)
75
+ await local.writeFile(path, bufferOrString) // returns count of bytes written
76
+ await s3.writeFile(path, bufferOrString) // returns count of bytes written
77
+
74
78
  // Delete a file
75
79
  // Quiet param is optional (default false), when set errors will not be thrown if the path does not exist
76
80
  const quiet = true
package/index.js CHANGED
@@ -43,6 +43,10 @@ const UTILITY_FUNCTIONS = {
43
43
  const chunks = []
44
44
  await client.read(path, reader(chunks))
45
45
  return Buffer.concat(chunks)
46
+ },
47
+ writeFile: (client) => async (path, data) => {
48
+ const readFunc = function* () { yield data }
49
+ return await client.write(path, readFunc)
46
50
  }
47
51
  }
48
52
 
@@ -51,7 +55,7 @@ function addUtilityFunctions (client, readOnly = false) {
51
55
  client[func] = UTILITY_FUNCTIONS[func](client)
52
56
  }
53
57
  if (readOnly) {
54
- for (const writeFunc of ['write', 'remove']) {
58
+ for (const writeFunc of ['write', 'remove', 'writeFile']) {
55
59
  client[writeFunc] = async () => {
56
60
  // console.warn(`${writeFunc} not supported in readOnly mode`)
57
61
  return false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobiletto",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "A storage abstraction layer",
5
5
  "main": "index.js",
6
6
  "author": "Jonathan Cobb",