Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Commit 9a8d85f

Browse files
chore(deps): drop dependency on is (#855)
1 parent 8b4040e commit 9a8d85f

6 files changed

Lines changed: 16 additions & 17 deletions

File tree

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
},
4545
"dependencies": {
4646
"@google-cloud/common": "^3.0.0",
47-
"@sindresorhus/is": "^1.0.0",
4847
"acorn": "^7.0.0",
4948
"coffeescript": "^2.0.0",
5049
"console-log-level": "^1.4.0",

src/agent/debuglet.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import is from '@sindresorhus/is';
1615
import * as assert from 'assert';
1716
import * as consoleLogLevel from 'console-log-level';
1817
import * as crypto from 'crypto';
@@ -546,7 +545,7 @@ export class Debuglet extends EventEmitter {
546545

547546
if (serviceContext) {
548547
if (
549-
is.string(serviceContext.service) &&
548+
typeof serviceContext.service === 'string' &&
550549
serviceContext.service !== 'default'
551550
) {
552551
// As per app-engine-ids, the module label is not reported
@@ -555,12 +554,12 @@ export class Debuglet extends EventEmitter {
555554
desc += ' module:' + serviceContext.service;
556555
}
557556

558-
if (is.string(serviceContext.version)) {
557+
if (typeof serviceContext.version === 'string') {
559558
labels.version = serviceContext.version;
560559
desc += ' version:' + serviceContext.version;
561560
}
562561

563-
if (is.string(serviceContext.minorVersion_)) {
562+
if (typeof serviceContext.minorVersion_ === 'string') {
564563
// v--- intentional lowercase
565564
labels.minorversion = serviceContext.minorVersion_;
566565
}

src/agent/state/inspector-state.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
// TODO: Unify some common code with state.ts in future PRs.
1616

17-
import is from '@sindresorhus/is';
1817
import * as inspector from 'inspector';
1918
import * as util from 'util';
2019

@@ -387,7 +386,7 @@ class StateResolver {
387386
} else {
388387
locals = this.resolveLocalsList_(frame);
389388

390-
if (is.emptyArray(locals)) {
389+
if (Array.isArray(locals) && locals.length === 0) {
391390
locals = [];
392391
}
393392
}
@@ -453,7 +452,13 @@ class StateResolver {
453452
objectId: frame.scopeChain[i].object.objectId as string,
454453
});
455454
// TODO: Handle when result.error exists.
456-
if (result.response && !is.emptyArray(result.response.result)) {
455+
if (
456+
result.response &&
457+
!(
458+
Array.isArray(result.response.result) &&
459+
result.response.result.length === 0
460+
)
461+
) {
457462
for (let j = 0; j < result.response.result.length; ++j) {
458463
if (!usedNames[result.response.result[j].name]) {
459464
// It's a valid variable that belongs in the locals list

src/agent/state/legacy-state.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import is from '@sindresorhus/is';
1615
import * as util from 'util';
1716
import * as vm from 'vm';
1817

@@ -366,7 +365,7 @@ class StateResolver {
366365
// in locals which will include any applicable arguments from the
367366
// invocation.
368367
locals = this.resolveLocalsList_(frame);
369-
if (is.emptyArray(locals)) {
368+
if (Array.isArray(locals) && locals.length === 0) {
370369
locals = [];
371370
}
372371
}

src/agent/util/utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import is from '@sindresorhus/is';
1615
import * as inspector from 'inspector';
1716
import * as path from 'path';
1817
import * as semver from 'semver';
@@ -65,7 +64,7 @@ export function findScripts(
6564
// (path: string, knownFiles: string[], resolved: string[]) => string[]
6665
const resolved = resolveScripts(scriptPath, config, fileStats);
6766
if (config.pathResolver) {
68-
if (!is.function_(config.pathResolver)) {
67+
if (typeof config.pathResolver !== 'function') {
6968
logger.warn(
7069
`The 'pathResolver' config must be a function. Continuing ` +
7170
`with the agent's default behavior.`

src/debuggee.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import is from '@sindresorhus/is';
16-
1715
import {PackageInfo} from './client/stackdriver/debug';
1816
import {StatusMessage} from './client/stackdriver/status-message';
1917

@@ -83,13 +81,13 @@ export class Debuggee {
8381

8482
properties = properties || {};
8583

86-
if (!is.string(properties.project)) {
84+
if (typeof properties.project !== 'string') {
8785
throw new Error('properties.project must be a string');
8886
}
89-
if (!is.string(properties.uniquifier)) {
87+
if (typeof properties.uniquifier !== 'string') {
9088
throw new Error('properties.uniquifier must be a string');
9189
}
92-
if (!is.string(properties.description)) {
90+
if (typeof properties.description !== 'string') {
9391
throw new Error('properties.description must be a string');
9492
}
9593

0 commit comments

Comments
 (0)