source: trip-planner-front/node_modules/stylus/lib/stack/scope.js@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1
2/*!
3 * Stylus - stack - Scope
4 * Copyright (c) Automattic <developer.wordpress.com>
5 * MIT Licensed
6 */
7
8/**
9 * Initialize a new `Scope`.
10 *
11 * @api private
12 */
13
14var Scope = module.exports = function Scope() {
15 this.locals = {};
16};
17
18/**
19 * Add `ident` node to the current scope.
20 *
21 * @param {Ident} ident
22 * @api private
23 */
24
25Scope.prototype.add = function(ident){
26 this.locals[ident.name] = ident.val;
27};
28
29/**
30 * Lookup the given local variable `name`.
31 *
32 * @param {String} name
33 * @return {Node}
34 * @api private
35 */
36
37Scope.prototype.lookup = function(name){
38 return hasOwnProperty(this.locals, name) ? this.locals[name] : undefined;
39};
40
41/**
42 * Custom inspect.
43 *
44 * @return {String}
45 * @api public
46 */
47
48Scope.prototype.inspect = function(){
49 var keys = Object.keys(this.locals).map(function(key){ return '@' + key; });
50 return '[Scope'
51 + (keys.length ? ' ' + keys.join(', ') : '')
52 + ']';
53};
54
55/**
56 * @param {Object} obj
57 * @param {String} propName
58 * @returns {Boolean}
59 */
60function hasOwnProperty(obj, propName) {
61 return Object.prototype.hasOwnProperty.call(obj, propName);
62}
Note: See TracBrowser for help on using the repository browser.