Skip to content

Instantly share code, notes, and snippets.

@Dicetog
Created August 11, 2014 02:39
Show Gist options
  • Save Dicetog/9ac531048282a8f5ecb4 to your computer and use it in GitHub Desktop.
Save Dicetog/9ac531048282a8f5ecb4 to your computer and use it in GitHub Desktop.
Bone101 Tutorial
<p style="font-size: 1.1em; line-height: 1.3em; color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);">Read the contents of a text (ASCII) file.</p><h2 style="font-size: 1.5em; font-family: Arial, Verdana, Helvetica, sans-serif; font-weight: normal; color: rgb(180, 162, 121); margin: 5px 0px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);">Arguments</h2><ul style="color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><li><em>filename</em>: complete path of the file to be read</li><li><em>callback</em>: called upon completion</li></ul><h2 style="font-size: 1.5em; font-family: Arial, Verdana, Helvetica, sans-serif; font-weight: normal; color: rgb(180, 162, 121); margin: 5px 0px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);">Return value</h2><ul style="color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><li>File contents in a single string</li></ul><h2 style="font-size: 1.5em; font-family: Arial, Verdana, Helvetica, sans-serif; font-weight: normal; color: rgb(180, 162, 121); margin: 5px 0px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);">callback(x)</h2><ul style="color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><li><em>x.data</em>: file contents</li><li><em>x.err</em>: error status message</li></ul>
var b = require('bonescript');
b.readTextFile('/etc/dogtag', printStatus);
function printStatus(x) {
console.log('x.data = ' + x.data);
console.log('x.err = ' + x.err);
}
<span style="font-weight: bold;">readTextFile(filename, [callback])</span><div><span style="font-weight: bold;"><br></span></div><div><span style="color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 13px; line-height: 17.15999984741211px;">Read the contents of a text (ASCII) file.</span><span style="font-weight: bold;"><br></span></div>
readTextFile
Arguments
Example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment