How to use the dissoc function from ramda
Find comprehensive JavaScript ramda.dissoc code examples handpicked from public code repositorys.
ramda.dissoc is a Ramda function that creates a new object with the specified property removed.
GitHub: joneshf/abstractions
155 156 157 158 159 160 161 162 163 164
return kvs.cata({ Put: function(key, val, next) { return interpretPure(next, R.assoc(key, val, store)); }, Del: function(key, next) { return interpretPure(next, R.dissoc(key, store)); }, Get: function(key, f) { return interpretPure(f(store[key]), store); }
+ 7 other calls in file
108 109 110 111 112 113 114 115 116 117
}, Put: function(str, val, cont) { return pureObject(cont, R.assoc(str, val, store)); }, Del: function(str, cont) { return pureObject(cont, R.dissoc(str, store)); }, }); }, });
How does ramda.dissoc work?
ramda.dissoc is a higher-order function in Ramda that creates a new object by omitting a property with the given key from the original object without mutating it. It takes two arguments: the property key to remove and the object from which to remove it. It returns a new object that has all the properties of the original object except the one with the given key. It uses the Object.assign method and spread syntax to create a shallow copy of the original object and remove the specified property. If the property is not found in the original object, the function returns the original object without any changes.
4 5 6 7 8 9 10 11 12 13
* Any coercion will not be performed, as they are removed prior to coercion. */ const removeUnsupportedOptions = R.compose( R.dissoc('q'), R.dissoc('silent'), R.dissoc('t'), R.dissoc('timestamp'), R.dissoc('blueprintPath'), R.dissoc('b'), R.dissoc('sandbox')
+ 23 other calls in file
GitHub: BizzoTech/kunafa-client
13 14 15 16 17 18 19 20 21 22
}; case "ADD_EVENT": case "UPDATE_EVENT": return R.assoc(action.doc._id, action.doc, state); case "REMOVE_EVENT": return R.dissoc(action.doc._id, state); case "LOGIN": case "LOGOUT": return defaultState; default:
Ai Example
1 2 3 4 5 6
const R = require("ramda"); const obj = { a: 1, b: 2, c: 3 }; const newObj = R.dissoc("b", obj); console.log(newObj); // { a: 1, c: 3 }
In this example, ramda.dissoc is used to remove the property with the key 'b' from the obj object. The resulting object newObj has all the properties of obj except for the 'b' property.
GitHub: corporatepiyush/es6
152 153 154 155 156 157 158 159 160 161 162
married: true } console.log("object keys =", _.keys(obj)) console.log("object values =", _.values(obj)) console.log("object add attribute =", _.assoc('height', 1.68, obj)) console.log("object remove attribute =", _.dissoc('nationality', obj)) console.log("object check attribute =", _.has('married', obj)) }
59 60 61 62 63 64 65 66 67 68
await addedDevice.save(); } user = user.toObject(); return { data: { user: dissoc('password', user), token } } } catch(error) {
+ 4 other calls in file
GitHub: moyataka/amberik-core
22 23 24 25 26 27 28 29 30 31
const refreshContext = R.evolve({ [cur_name]: { retain: R.always(max_retain), } }) const purge = R.dissoc(cur_name) const getKeepCtxName = R.path(['_keep', 'ctx', 'name']) return (prev, nex) => {
GitHub: asan1010/apk
45 46 47 48 49 50 51 52 53 54
* Get the rankings of the app in the top list and top category list and score * them. */ function getCollectionScores (app) { const categoryQuery = store.getCollectionQuery(app); const globalQuery = R.dissoc('category', categoryQuery); return Promise.all([ store.list(globalQuery), store.list(categoryQuery)
+ 270 other calls in file
GitHub: areca/misc
1242 1243 1244 1245 1246 1247 1248 1249 1250 1251
* @sig String -> a -> {k: v} -> {k: v} * @param {String} prop the property name to set * @param {*} val the new value * @param {Object} obj the object to clone * @return {Object} a new object similar to the original except for the specified property. * @see R.dissoc * @example * * R.assoc('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3} */
+ 37 other calls in file
ramda.clone is the most popular function in ramda (30311 examples)