Socket
Socket
Sign inDemoInstall

parent-module

Package Overview
Dependencies
1
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 1.0.0

18

index.js
'use strict';
var callsites = require('callsites');
const callsites = require('callsites');
module.exports = function (filepath) {
var stacks = callsites();
module.exports = filepath => {
const stacks = callsites();

@@ -11,8 +11,10 @@ if (!filepath) {

var seenVal = false;
let seenVal = false;
// skip the first stack as it's this function
for (var i = 1; i < stacks.length; i++) {
var parentFilepath = stacks[i].getFileName();
// Skip the first stack as it's this function
stacks.shift();
for (const stack of stacks) {
const parentFilepath = stack.getFileName();
if (parentFilepath === filepath) {

@@ -23,3 +25,3 @@ seenVal = true;

// skip native modules
// Skip native modules
if (parentFilepath === 'module.js') {

@@ -26,0 +28,0 @@ continue;

{
"name": "parent-module",
"version": "0.1.0",
"description": "Get the path of the parent module",
"license": "MIT",
"repository": "sindresorhus/parent-module",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"parent",
"module",
"package",
"pkg",
"caller",
"calling",
"module",
"path",
"callsites",
"callsite",
"stacktrace",
"stack",
"trace",
"function",
"file"
],
"dependencies": {
"callsites": "^1.0.0"
},
"devDependencies": {
"ava": "*",
"execa": "^0.2.2",
"xo": "*"
}
"name": "parent-module",
"version": "1.0.0",
"description": "Get the path of the parent module",
"license": "MIT",
"repository": "sindresorhus/parent-module",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"parent",
"module",
"package",
"pkg",
"caller",
"calling",
"module",
"path",
"callsites",
"callsite",
"stacktrace",
"stack",
"trace",
"function",
"file"
],
"dependencies": {
"callsites": "^3.0.0"
},
"devDependencies": {
"ava": "^1.0.1",
"execa": "^1.0.0",
"xo": "^0.23.0"
}
}

@@ -38,3 +38,3 @@ # parent-module [![Build Status](https://travis-ci.org/sindresorhus/parent-module.svg?branch=master)](https://travis-ci.org/sindresorhus/parent-module)

By default it will return the path of the immediate parent.
By default, it will return the path of the immediate parent.

@@ -60,3 +60,3 @@ #### filepath

console.log(readPkgUp.sync({cwd: path.dirname(parentModule)}).pkg);
console.log(readPkgUp.sync({cwd: path.dirname(parentModule())}).pkg);
//=> {name: 'chalk', version: '1.0.0', ...}

@@ -68,2 +68,2 @@ ```

MIT © [Sindre Sorhus](http://sindresorhus.com)
MIT © [Sindre Sorhus](https://sindresorhus.com)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc