Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gamtiq/basespace
Functions to create namespaces inside objects
https://github.com/gamtiq/basespace
Last synced: about 8 hours ago
JSON representation
Functions to create namespaces inside objects
- Host: GitHub
- URL: https://github.com/gamtiq/basespace
- Owner: gamtiq
- Created: 2013-06-23T11:03:35.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-01-09T22:15:50.000Z (almost 10 years ago)
- Last Synced: 2024-10-27T22:32:50.545Z (12 days ago)
- Language: JavaScript
- Size: 211 KB
- Stars: 6
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: History.md
Awesome Lists containing this project
README
# basespace
Functions to create namespaces inside objects.
## Installation
### Node
npm install basespace
### [Component](https://github.com/componentjs/component)
component install gamtiq/basespace
### [Jam](http://jamjs.org)
jam install basespace
### [Bower](http://bower.io)
bower install basespace
### [SPM](http://spmjs.io)
spm install numgen
### AMD, script tag
Use `dist/basespace.js` or `dist/basespace.min.js` (minified version).
## Usage
### Node, Component, SPM
```js
var ns = require("basespace");
...
```### Jam
```js
require(["basespace"], function(ns) {
...
});
```### AMD
```js
define(["path/to/dist/basespace.js"], function(ns) {
...
});
```### Bower, script tag
```html
// basespace is available via basespace field of window object
var ns = basespace;
...```
## Example
```js
var app = {
space: ns.space
};
ns(["model", "ui.dialog", "ui.list", "ui.list.cyclic", "util"], app);
app.space("ui.menu", "template");
app.space("data").util = {...};
```## API
### ns(namespaces: Array|String, [context: Object], [value])
Create specified `namespaces` inside `context` if they do not exist.
`context` is global object (i.e. `window` in browser) by default.
`value` specifies a value that will be assigned to a final field. `{}` by default.Return the value for the last of created names/fields.
### .space(namespace: String, ...)
Create the specified `namespace` inside `this` object.
Return the value for the last of created names/fields.
## Related projects
* [extend](https://github.com/gamtiq/extend)
* [mixing](https://github.com/gamtiq/mixing)## Licence
MIT