@snap-fileio/extension
v1.1.0
Published
Snap! extension that lets Snap! programs read and write files on the local filesystem via a Node.js middleware server.
Downloads
210
Maintainers
Readme
snap-fileio / extension
This is the Snap! File I/O Extension, a loadable JavaScript extension for the Snap! visual programming environment that enables Snap! programs to read and write files on the local filesystem via a Node.js middleware server.
The extension registers 13 primitives (8 plain-text, 4 structured data, 1 error reporter) and injects a "File I/O" block category into the Snap! palette. It communicates with the middleware over HTTP REST, targeting any server that implements the API contract.
The extension is consumed by snap-out, which provides the Electron shell, Express server, and workspace configuration.
Blocks
Commands
| Block | Description |
|---|---|
| write %path content %content | Create or overwrite a text file |
| append %content to %path | Append text to a file |
| delete file %path | Delete a file |
| create directory %path | Create a directory |
| write CSV %path data %data delimiter %delim | Write list-of-lists as CSV |
| write JSON %path data %data | Write Snap! data as JSON |
Reporters
| Block | Returns |
|---|---|
| read file %path | String |
| read lines of %path | List of strings |
| list files in %path | List of entry names |
| file %path exists | Boolean |
| read CSV %path delimiter %delim | List of lists |
| read JSON %path | Snap! data (objects as list-of-pairs) |
| last error | Error message string, or empty |
Building
The extension is bundled into a single IIFE file for browser loading:
npm run buildOutput: dist/snap-fileio-extension.js
Testing
npm testLicense
The Snap! File I/O extension is free software. You may redistribute and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.
