// Creating a Space Objectvar person = new Space('name John')// Accessing a property console.log(person.get('name'))// Setting a propertyperson.set('age', 29)// Printing the objectconsole.log(person.toString())
Examples
Here's how I could write a tax return in Space:
socialSecurityNumber 555-55-5555name John SmithtaxYear 2012income 10,000dependents 1exemptions 2address 123 Main Streetcity San Franciscostate California
Space supports recursion. Here's an example of web page stats:
homepage pageviews 2312 uniques 231 referers about 23 contact 41about pageviews 314 uniques 201 referers home 100 contact 21contact pageviews 214 uniques 124 referers home 110 about 10
Working with the above stats example:
var stats = new Space(exampleStringFromAbove)// Get a nested property using an xpath like querystats.get('contact referers home')// Returns 110stats.set('about uniques', 500)
Copyright (C) 2015 Breck Yunits - Released under the MIT License.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.