New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

isotropy-ast-analyzer-filesystem

Package Overview
Dependencies
Maintainers
4
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isotropy-ast-analyzer-filesystem

Isotropy AST Analyzer for FS ============================ This module abstracts AST analysis for common filesystem operations so that they don't have to be repeated in every filesystem plugin. This is part of the isotropy framework (www.isotropy.org).

  • 0.0.8
  • latest
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

Isotropy AST Analyzer for FS

This module abstracts AST analysis for common filesystem operations so that they don't have to be repeated in every filesystem plugin. This is part of the isotropy framework (www.isotropy.org).

Create a module "fs.js" containing an array that mocks the filesystem. The filename can be changed in configuration.

//In fs.js
export default [
  {
    { dir: "pictures", filename: "stock_photo1.jpg", contents: "FF D8 FF ..." },
    { dir: "trash", filename: "not-passwords.txt", contents: "thisisnotpassword" }
  }
]

Create a file

import myFS from "./my-fs.js";

async function createFile() {
  myFS.docs = myFS.docs.concat({
    dir: "path/to/docs/",
    filename: "report.txt",
    contents: "hello, world"
  });
}

Read a file

import myFS from "./my-fs.js";

async function readFile() {
  return myFS.docs.find(file => file.dir === "path/to/docs/" && file.filename === "report.txt");
}

Get all files in a directory

import myFS from "../my-fs";

async function getFiles() {
  return myFS.docs.filter(file => file.dir === "path/to/docs/");
}

Get all files in a directory recursively down to the last level of directories

import myFS from "../my-fs";

async function getFiles() {
  return myFS.docs.filter(
    file => file.dir === "path/to/docs/" || file.dir.startsWith("path/to/docs/")
  );
}

Update a file

import myFS from "./my-fs.js";

async function updateFile() {
  myFS.docs = myFS.docs.map(
    file =>
      file.dir === "path/to/docs/" && file.filename === "report.txt"
        ? { ...file, contents: "hello, universe" }
        : file
  );
}

Delete a file

import myFS from "../my-fs";

async function deleteFile() {
  myFS.docs = myFS.docs.filter(
    file => !(file.dir === "path/to/docs/" && file.filename === "report.txt")
  );
}

Delete a directory

import myFS from "../my-fs";

async function deleteDir() {
  myFS.docs = myFS.docs.filter(file => !(file.dir === "path/to/docs/"));
}

Move a file

import myFS from "../my-fs";

async function moveFile() {
  myFS.docs = myFS.docs.map(
    file =>
      file.dir === "path/to/docs/" && file.filename === "report.txt"
        ? { ...file, dir: "path/to/reports/", filename: "report.txt" }
        : file
  );
}

Move a directory

import myFS from "../my-fs";

async function moveFile() {
  myFS.docs = myFS.docs.map(
    file => (file.dir === "path/to/docs/" ? { ...file, dir: "path/to/reports/" } : file)
  );
}

FAQs

Package last updated on 02 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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