Sha256: 97d45b2adc294d37152970cbec3f5e3a1dc82af5873c1e56298a05f2a977d9bb

Contents?: true

Size: 1.12 KB

Versions: 19

Compression:

Stored size: 1.12 KB

Contents

/** internal
 *  class StaticAsset
 *
 *  Represents static asset the one that has no any processors associated with.
 *
 *
 *  ##### SUBCLASS OF
 *
 *  [[Asset]]
 **/


'use strict';


// stdlib
var fs = require('fs');


// internal
var prop    = require('../common').prop;
var getter  = require('../common').getter;
var Asset   = require('./asset');


////////////////////////////////////////////////////////////////////////////////


/**
 *  new StaticAsset()
 *
 *  See [[Asset.new]] for details.
 **/
var StaticAsset = module.exports = function StaticAsset() {
  Asset.apply(this, arguments);
  prop(this, 'type', 'static');
};


require('util').inherits(StaticAsset, Asset);


// See apidoc of [[Asset#buffer]]
getter(StaticAsset.prototype, 'buffer', function () {
  // No caching to avoid memory bloating by default.
  // Caching might be implemented on the higher level (e.g. in [[Server]])
  // by simply setting `__buffer__` property.
  return this.__buffer__ || fs.readFileSync(this.pathname);
});


// See apidoc of [[Asset#source]]
getter(StaticAsset.prototype, 'source', function () {
  return this.buffer.toString('binary');
});

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ela-4.1.6 node_modules/mincer/lib/mincer/assets/static.js
ela-4.1.5 node_modules/mincer/lib/mincer/assets/static.js
ela-4.1.4 node_modules/mincer/lib/mincer/assets/static.js
ela-4.1.3 node_modules/mincer/lib/mincer/assets/static.js
ela-4.1.2 node_modules/mincer/lib/mincer/assets/static.js
ela-4.1.1 node_modules/mincer/lib/mincer/assets/static.js
ela-4.1.0 node_modules/mincer/lib/mincer/assets/static.js
ela-4.0.0 node_modules/mincer/lib/mincer/assets/static.js
ela-3.4.3 node_modules/mincer/lib/mincer/assets/static.js
ela-3.4.2 node_modules/mincer/lib/mincer/assets/static.js
ela-3.4.0 node_modules/mincer/lib/mincer/assets/static.js
ela-3.3.1 node_modules/mincer/lib/mincer/assets/static.js
ela-3.3.0 node_modules/mincer/lib/mincer/assets/static.js
ela-3.2.0 node_modules/mincer/lib/mincer/assets/static.js
ela-3.1.1 node_modules/mincer/lib/mincer/assets/static.js
ela-3.1.0 node_modules/mincer/lib/mincer/assets/static.js
ela-3.0.0 node_modules/mincer/lib/mincer/assets/static.js
ela-2.0.0 node_modules/mincer/lib/mincer/assets/static.js
ela-1.1.0 node_modules/mincer/lib/mincer/assets/static.js