Open Anima-t3d opened 8 years ago
I never saw that before. Why do you ever need this? :D
You would need it when the key contains .
or -
They aren't allowed as variable names! You can check whether it's allowed or not here: https://mothereff.in/js-variables
They aren't allowed as variable names!
I wasn't referring to variable name. I was referring to JavaScript property names and they are allowed see https://mothereff.in/js-properties but: You need to quote this property name
I hope that is more clear?
@Wikunia can you please include this? It is often used in js when writing Meteor.methods in Meteor.
Example in ES6:
Meteor.methods({
'todos.updateText'({ todoId, newText }) {
new SimpleSchema({
todoId: { type: String },
newText: { type: String }
}).validate({ todoId, newText });
const todo = Todos.findOne(todoId);
if (!todo.editableBy(this.userId)) {
throw new Meteor.Error('todos.updateText.unauthorized',
'Cannot edit todos in a private list that is not yours');
}
Todos.update(todoId, {
$set: { text: newText }
});
}
});
Thanks.
Unfortunately that '
stuff isn't the only problem here :/
Don't have much time to work on that one. At the moment the extension works using regular expressions (see readme) and it would be best to have a real parser for that. But at the moment my time is limited as well as the financial support. I'm sorry for that one :(
The problem at your example is that ES6 isn't really supported in my extension so destructuring doesn't work at the moment.
I noticed the usage of regular expressions. I am mainly interested in the support for '
and can completely understand you not being able to support the quirky stuff ES6 brings. I just showed the example on the official guide, which happens to use ES6.
Your efforts are very much appreciated! Thanks!
A named expression with the key being a string is not recognised. See
'hello2'