presidium 3.0.1 → 3.0.3

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.
@@ -788,7 +788,7 @@ class GoogleChromeDevToolsRuntime {
788
788
  *
789
789
  * The Chrome DevTools Protocol has various APIs to interact with the different parts of the browser. These parts are separated into different domains. The Presidium GoogleChromeDevTools client covers the `Target`, `Page`, `DOM`, `Input`, `Storage`, and `Runtime` domains. Pages, serviceworkers, and extensions are called "Targets" and can be fetched and tracked using the `Target` domain.
790
790
  *
791
- * Every Chrome DevTools Protocol client needs to first attach to the target using the `Target.attachToTarget` command. The command will establish a protocol session with the given target and return a `sessionId`. The returned `sessionId` should be included in every message to the DevTools server.
791
+ * Every Chrome DevTools Protocol client needs to first attach to the target using the `Target.attachToTarget` command. The command will establish a protocol session with the given target and return a `sessionId`. The returned `sessionId` should be set on the `GoogleChromeDevTools` client using [`setSessionId`](#setSessionId) or included in every message to the DevTools server.
792
792
  *
793
793
  * ```javascript
794
794
  * const googleChromeDevTools = new GoogleChromeDevTools()
@@ -828,7 +828,21 @@ class GoogleChromeDevTools extends EventEmitter {
828
828
  *
829
829
  * @docs
830
830
  * ```coffeescript [specscript]
831
- * init() -> Promise<>
831
+ * init() -> promise Promise<>
832
+ * ```
833
+ *
834
+ * Initializes the `GoogleChromeDevTools` client.
835
+ *
836
+ * Arguments:
837
+ * * (none)
838
+ *
839
+ * Returns:
840
+ * * `promise` - a promise that resolves when the initialization process is done.
841
+ *
842
+ * ```javascript
843
+ * const googleChromeDevTools = new GoogleChromeDevTools()
844
+ *
845
+ * await googleChromeDevTools.init()
832
846
  * ```
833
847
  */
834
848
  async init() {
package/index.js CHANGED
@@ -5,6 +5,7 @@ module.exports = {
5
5
  DynamoDBStream: require('./DynamoDBStream.js'),
6
6
  DynamoDBTable: require('./DynamoDBTable.js'),
7
7
  ECR: require('./ECR.js'),
8
+ GoogleChromeDevTools: require('./GoogleChromeDevTools.js'),
8
9
  HTTP: require('./HTTP.js'),
9
10
  NpmToken: require('./NpmToken.js'),
10
11
  OptionalValidator: require('./OptionalValidator.js'),
@@ -1,13 +1,7 @@
1
1
  require('rubico/global')
2
2
  const tarStream = require('tar-stream')
3
- const fs = require('fs/promises')
3
+ const fs = require('fs')
4
4
  const walk = require('./walk')
5
- const pipe = require('rubico/pipe')
6
- const tap = require('rubico/tap')
7
- const get = require('rubico/get')
8
- const reduce = require('rubico/reduce')
9
- const thunkify = require('rubico/thunkify')
10
- const pick = require('rubico/pick')
11
5
 
12
6
  /**
13
7
  * @name Archive
@@ -54,10 +48,10 @@ Archive.tar = function tar(path, options) {
54
48
  pack.entry({
55
49
  name: filepath.replace(pathWithSlash, ''),
56
50
  ...pipe([
57
- fs.stat,
51
+ fs.promises.stat,
58
52
  pick(['size', 'mode', 'mtime', 'uid', 'gid']),
59
53
  ])(filepath),
60
- }, await fs.readFile(filepath))
54
+ }, await fs.promises.readFile(filepath))
61
55
  return pack
62
56
  }, pack),
63
57
 
@@ -29,11 +29,18 @@ const test = new Test('Archive', async function integration() {
29
29
  const base = {
30
30
  Dockerfile: 'FROM node:15-alpine'
31
31
  }
32
- const ignore = ['fixtures']
32
+ const ignore = ['fixtures', 'tmp', 'google-chrome-for-testing']
33
33
  const pack = await Archive.tar(__dirname, { ignore, base })
34
34
  const extracted = await Archive.untar(pack)
35
35
  const dir = await fs.readdir(__dirname)
36
- .then(filter(n => !ignore.includes(n)))
36
+ .then(filter(filepath => {
37
+ for (const part of ignore) {
38
+ if (filepath.includes(part)) {
39
+ return false
40
+ }
41
+ }
42
+ return true
43
+ }))
37
44
  const extractedKeys = [...extracted.keys()]
38
45
  assert.equal(extracted.size, dir.length + 1) // extra Dockerfile
39
46
  assert(extracted.has('Dockerfile'))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "presidium",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "A library for creating web services",
5
5
  "author": "Richard Tong",
6
6
  "license": "MIT",
package/internal/tmp.js DELETED
@@ -1,38 +0,0 @@
1
- // Generate CRC32C lookup table (Castagnoli polynomial)
2
- const CRC32C_TABLE = (() => {
3
- const table = new Uint32Array(256)
4
- const poly = 0x1EDC6F41
5
- for (let i = 0; i < 256; i++) {
6
- let crc = i
7
- for (let j = 0; j < 8; j++) {
8
- crc = (crc & 1) ? (crc >>> 1) ^ poly : (crc >>> 1)
9
- }
10
- table[i] = crc >>> 0
11
- }
12
- return table
13
- })()
14
-
15
- /**
16
- * Calculate CRC32C checksum of a string or Uint8Array
17
- * @param {string | Uint8Array | Buffer} input
18
- * @returns {number} 32-bit unsigned integer checksum
19
- */
20
- function crc32c(input) {
21
- if (typeof input === 'string') {
22
- input = new TextEncoder().encode(input) // Convert string to Uint8Array
23
- }
24
-
25
- let crc = 0xFFFFFFFF
26
- for (let i = 0; i < input.length; i++) {
27
- const byte = input[i]
28
- const index = (crc ^ byte) & 0xFF
29
- crc = (crc >>> 8) ^ CRC32C_TABLE[index]
30
- }
31
-
32
- return (crc ^ 0xFFFFFFFF) >>> 0
33
- }
34
-
35
- module.exports = crc32c
36
-
37
- // Example usage:
38
- // console.log(crc32c('test').toString(16)) // → "e3069283"