Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
serialize(options = {}) {
const { resources, count, model } = this;
const i = inflect();
const data = [];
const included = [];
const plural = i.pluralize(model.type);
const namespace = undefined !== options.namespace
? `/${options.namespace}`
: ``;
const links = {
self: `${namespace}/${plural}`,
};
// TODO: default limit
if ('page' in options) {
let limit = options.page.limit || 0;
let offset = options.page.offset || 0;
links.page = {};
serializeResourceObject(fields, type, doc, many) {
if (!doc) {
throw new Error('Cannot serialize an undefined object!');
}
// FIXME: create global inflect so not to call the constructor every time
const i = inflect();
const id = doc._id;
if (!fields) {
throw new Error('Trying to serialize before fields have been established.');
}
if (!id) {
throw new Error('Cannot serialize document with undefined id.');
}
// TODO: create method for building a resource object URL
const resourceObject = {
data: {
type: i.singularize(type),
id: id,
},
serializeResource(router, type, document) {
const fields = router.fields;
const i = inflect();
let id = document._id;
// build resource object
let resource = this._resource = {
links: {
self: baseUrl(router.origin, router.port, router.namespace, type, id),
},
id: id,
type: parseModelName(type),
};
// loop through the raw Mongo object
_.forOwn(document, (value, field) => {
let isFieldAttribute = hasAttribute(fields, type, field);
let isFieldRelationship = hasRelationship(fields, type, field);
var config = require('../../config');
var csv = require('csv');
var getUri = require('get-uri');
var highlight = require('highlight-redux');
var jsonEditor = require('./jsoneditform');
// This import is just for extending json editor with custom editor
var resourceEditor = require('./resource-editor');
var jtsInfer = require('json-table-schema').infer;
var registry = require('./registry');
var request = require('superagent-bluebird-promise');
var _ = require('underscore');
var $ = require('jquery');
var Promise = require('bluebird');
var titleize = require('i')().titleize;
// Upload data file and populate .resource array with item
DataUploadView = backbone.BaseView.extend({
addRow: function(name) {
var descriptorEdit = window.APP.layout.descriptorEdit;
descriptorEdit.layout.form.getEditor('root.resources').add({name: name, path: name});
descriptorEdit.populateTitlesFromNames();
return this;
},
hideLoading: function() { window.APP.layout.splashScreen.activate(false); return this; },
events: {
// 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.
//
// Abbreviations with `.` but are never are EOS.
const abbrvNoEOS = Object.create( null );
abbrvNoEOS[ 'mr.' ] = true;
abbrvNoEOS[ 'mrs.' ] = true;
abbrvNoEOS[ 'ms.' ] = true;
abbrvNoEOS[ 'er.' ] = true;
abbrvNoEOS[ 'dr.' ] = true;
abbrvNoEOS[ 'miss.' ] = true;
abbrvNoEOS[ 'shri.' ] = true;
abbrvNoEOS[ 'smt.' ] = true;
abbrvNoEOS[ 'i.e.' ] = true;
abbrvNoEOS[ 'ie.' ] = true;
abbrvNoEOS[ 'e.g.' ] = true;
abbrvNoEOS[ 'eg.' ] = true;
abbrvNoEOS[ 'viz.' ] = true;
abbrvNoEOS[ 'pvt.' ] = true;
// et al.
abbrvNoEOS[ 'et.' ] = true;
abbrvNoEOS[ 'al.' ] = true;
// Mount Kailash!
abbrvNoEOS[ 'mt.' ] = true;
// Pages!
abbrvNoEOS[ 'pp.' ] = true;
const abbrvMayBeEOS = Object.create( null );
abbrvMayBeEOS[ 'inc.' ] = true;
abbrvMayBeEOS[ 'ltd.' ] = true;
return new Promise((resolve, reject) => {
let followers = [];
let following = [];
const sessionStorage = session._cookiesStore.storage
const accountId = (sessionStorage.idx['instagram.com'] || sessionStorage.idx['i.instagram.com'])['/'].ds_user_id.value
const compare = () => {
hashedFollowers = {}
followers.forEach((user) => hashedFollowers[user.id] = true);
let unfollowers = following.filter((user) => !hashedFollowers[user.id]);
resolve(unfollowers);
}
const getUsers = (newUsers, allUsers, usersGetter, otherUsersGetter) => {
newUsers.forEach((user) => allUsers.push(user))
// moreAvailable maybe null. We are dodging that.
if (usersGetter.moreAvailable === false && otherUsersGetter.moreAvailable === false){
compare();
} else if (usersGetter.moreAvailable !== false) {
usersGetter.get()
test('groupCasesBySelector', function () {
var _test = new libs.Test('fakeLinkTest', {
'type': 'selector',
'options': {
'selector': 'i.unittest',
}
});
_test.invoke();
var casesBySelector = _test.groupCasesBySelector();
equal(casesBySelector['i.unittest'].length, 10, 'Cases are grouped by selector');
});
asyncTest('groupCasesByHtml', function () {
cache.get('/i.png', function (data) {
assert.deepEqual(data.body, files['i.png']);
next();
});
},
const select = (property, value, schema, onChange) => {
return
}
import Vue from 'vue'
import inflector from 'i'
const storage = window.localStorage
let helper = {}
/**
* string processor
*/
helper.i = inflector()
/**
* localStorage
*/
helper.ls = {
set (key, value) {
value = JSON.stringify(value)
storage.setItem(key, value)
},
get (key, defaultValue) {
let value = storage.getItem(key, value)
if (value === null || value === 'undefined' || value === '') {
value = defaultValue
} else {
value = JSON.parse(value)
}